[Bots/Mercs] Add 100% Hit chance if sitting while attacked. (#2839)

* [BOT] Add 100% Hit chance if sitting while attacked.

* [BOT] Add 100% Hit chance if sitting while attacked.

* Add Mercs correctly

* Missed usage of IsSitting() in Mob::RollD20
This commit is contained in:
Aeadoin 2023-02-06 22:30:33 -05:00 committed by GitHub
parent 158396937a
commit b0d1dc5f04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 9 deletions

View File

@ -317,8 +317,9 @@ bool Mob::CheckHitChance(Mob* other, DamageHitInfo &hit)
Mob *defender = this;
Log(Logs::Detail, Logs::Attack, "CheckHitChance(%s) attacked by %s", defender->GetName(), attacker->GetName());
if (defender->IsClient() && defender->CastToClient()->IsSitting())
if ((defender->IsClient() || defender->IsBot() || defender->IsMerc()) && defender->IsSitting()) {
return true;
}
auto avoidance = defender->GetTotalDefense();
if (avoidance == -1) // some sort of auto avoid disc
@ -1001,8 +1002,9 @@ double Mob::RollD20(int offense, int mitigation)
1.6, 1.7, 1.8, 1.9, 2.0
};
if (IsClient() && CastToClient()->IsSitting())
if ((IsClient() || IsBot() || IsMerc()) && IsSitting()) {
return mods[19];
}
auto atk_roll = zone->random.Roll0(offense + 5);
auto def_roll = zone->random.Roll0(mitigation + 5);

View File

@ -571,7 +571,7 @@ void Bot::Stand() {
SetAppearance(eaStanding);
}
bool Bot::IsSitting() {
bool Bot::IsSitting() const {
bool result = false;
if(GetAppearance() == eaSitting && !IsMoving())
result = true;

View File

@ -219,7 +219,7 @@ public:
void ChangeBotArcherWeapons(bool isArcher);
void Sit();
void Stand();
bool IsSitting();
bool IsSitting() const override;
bool IsStanding();
int GetWalkspeed() const override { return (int)((float)_GetWalkSpeed() * 1.785714285f); } // 1.25 / 0.7 = 1.7857142857142857142857142857143
int GetRunspeed() const override { return (int)((float)_GetRunSpeed() * 1.785714285f); }

View File

@ -841,9 +841,9 @@ public:
void Fling(float value, float target_x, float target_y, float target_z, bool ignore_los = false, bool clip_through_walls = false, bool calculate_speed = false);
inline bool IsStanding() const {return (playeraction == 0);}
inline bool IsSitting() const {return (playeraction == 1);}
inline bool IsCrouching() const {return (playeraction == 2);}
inline bool IsStanding() const { return (playeraction == 0); }
inline bool IsSitting() const override { return (playeraction == 1); }
inline bool IsCrouching() const { return (playeraction == 2); }
inline bool IsBecomeNPC() const { return npcflag; }
inline uint8 GetBecomeNPCLevel() const { return npclevel; }
inline void SetBecomeNPC(bool flag) { npcflag = flag; }

View File

@ -4292,7 +4292,7 @@ void Merc::Stand() {
SetAppearance(eaStanding);
}
bool Merc::IsSitting() {
bool Merc::IsSitting() const {
bool result = false;
if(GetAppearance() == eaSitting && !IsMoving())

View File

@ -257,7 +257,7 @@ public:
void Sit();
void Stand();
bool IsSitting();
bool IsSitting() const override;
bool IsStanding();
// Merc-specific functions

View File

@ -657,7 +657,11 @@ public:
inline int32 GetHeroicStrikethrough() const { return heroic_strikethrough; }
inline const bool GetKeepsSoldItems() const { return keeps_sold_items; }
inline void SetKeepsSoldItems(bool in_keeps_sold_items) { keeps_sold_items = in_keeps_sold_items; }
virtual bool IsSitting() const { return false; }
int CalcRecommendedLevelBonus(uint8 level, uint8 reclevel, int basestat);
void CopyHateList(Mob* to);
//Group