[Bots] Add IsBot() to methods in attack.cpp where applicable. (#2840)

* [Bots] add IsBot() to methods in attack.cpp where applicable.

* Add mercs where applicable

* Cleanup verbose if statements

* typo

* Fix other spots missed.
This commit is contained in:
Aeadoin 2023-02-09 10:36:01 -05:00 committed by GitHub
parent 106cb45b57
commit 7064a4156f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 25 deletions

View File

@ -248,7 +248,7 @@ int Mob::compute_defense()
{
int defense = GetSkill(EQ::skills::SkillDefense) * 400 / 225;
defense += (8000 * (GetAGI() - 40)) / 36000;
if (IsClient() || IsBot()) {
if (IsOfClientBot()) {
defense += GetHeroicAGI() / 10;
}
@ -318,7 +318,7 @@ 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->IsBot() || defender->IsMerc()) && defender->IsSitting()) {
if (defender->IsOfClientBotMerc() && defender->IsSitting()) {
return true;
}
@ -873,7 +873,7 @@ int Mob::ACSum(bool skip_caps)
int ac = 0; // this should be base AC whenever shrouds come around
ac += itembonuses.AC; // items + food + tribute
int shield_ac = 0;
if (HasShieldEquiped() && (IsClient() || IsBot())) {
if (HasShieldEquiped() && IsOfClientBot()) {
auto inst = (IsClient()) ? GetInv().GetItem(EQ::invslot::slotSecondary) : CastToBot()->GetBotItem(EQ::invslot::slotSecondary);
if (inst) {
if (inst->GetItemRecommendedLevel(true) <= GetLevel()) {
@ -887,8 +887,9 @@ int Mob::ACSum(bool skip_caps)
// EQ math
ac = (ac * 4) / 3;
// anti-twink
if (!skip_caps && IsClient() && GetLevel() < RuleI(Combat, LevelToStopACTwinkControl))
if (!skip_caps && IsOfClientBot() && GetLevel() < RuleI(Combat, LevelToStopACTwinkControl)) {
ac = std::min(ac, 25 + 6 * GetLevel());
}
ac = std::max(0, ac + GetClassRaceACBonus());
if (IsNPC()) {
// This is the developer tweaked number
@ -917,7 +918,7 @@ int Mob::ACSum(bool skip_caps)
if (ac < 0)
ac = 0;
if (!skip_caps && (IsClient() || IsBot())) {
if (!skip_caps && IsOfClientBot()) {
auto softcap = GetACSoftcap();
auto returns = GetSoftcapReturns();
int total_aclimitmod = aabonuses.CombatStability + itembonuses.CombatStability + spellbonuses.CombatStability;
@ -1003,7 +1004,7 @@ double Mob::RollD20(int offense, int mitigation)
1.6, 1.7, 1.8, 1.9, 2.0
};
if ((IsClient() || IsBot() || IsMerc()) && IsSitting()) {
if (IsOfClientBotMerc() && IsSitting()) {
return mods[19];
}
@ -3538,7 +3539,7 @@ bool Mob::HasProcs() const
}
}
if (IsClient() || IsBot()) {
if (IsOfClientBot()) {
for (int i = 0; i < MAX_AA_PROCS; i += 4) {
if (aabonuses.SpellProc[i]) {
return true;
@ -3556,7 +3557,7 @@ bool Mob::HasDefensiveProcs() const
}
}
if (IsClient() || IsBot()) {
if (IsOfClientBot()) {
for (int i = 0; i < MAX_AA_PROCS; i += 4) {
if (aabonuses.DefensiveProc[i]) {
return true;
@ -3592,7 +3593,7 @@ bool Mob::HasRangedProcs() const
}
}
if (IsClient() || IsBot()) {
if (IsOfClientBot()) {
for (int i = 0; i < MAX_AA_PROCS; i += 4) {
if (aabonuses.RangedProc[i]) {
return true;
@ -3960,10 +3961,11 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
if (attacker) {
if (skill_used == EQ::skills::SkillBash) {
can_stun = true;
if (attacker->IsClient())
if (attacker->IsClient() || attacker->IsBot() || attacker->IsMerc()) {
stunbash_chance = attacker->spellbonuses.StunBashChance +
attacker->itembonuses.StunBashChance +
attacker->aabonuses.StunBashChance;
attacker->itembonuses.StunBashChance +
attacker->aabonuses.StunBashChance;
}
}
else if (skill_used == EQ::skills::SkillKick &&
(attacker->GetLevel() > 55 || attacker->IsNPC()) && GetClass() == WARRIOR) {
@ -4454,7 +4456,7 @@ void Mob::TryDefensiveProc(Mob *on, uint16 hand) {
}
//AA Procs
if (IsClient() || IsBot()){
if (IsOfClientBot()) {
for (int i = 0; i < MAX_AA_PROCS; i += 4) {
int32 aa_rank_id = aabonuses.DefensiveProc[i + +SBIndex::COMBAT_PROC_ORIGIN_ID];
int32 aa_spell_id = aabonuses.DefensiveProc[i + SBIndex::COMBAT_PROC_SPELL_ID];
@ -4712,7 +4714,7 @@ void Mob::TrySpellProc(const EQ::ItemInstance *inst, const EQ::ItemData *weapon,
}
//AA Melee and Ranged Procs
if (IsClient() || IsBot()) {
if (IsOfClientBot()) {
for (int i = 0; i < MAX_AA_PROCS; i += 4) {
int32 aa_rank_id = 0;
@ -5162,8 +5164,9 @@ void Mob::ApplyMeleeDamageMods(uint16 skill, int64 &damage, Mob *defender, Extra
dmgbonusmod += opts->melee_damage_bonus_flat;
if (defender) {
if (defender->IsClient() && defender->GetClass() == WARRIOR)
if (defender->IsOfClientBotMerc() && defender->GetClass() == WARRIOR) {
dmgbonusmod -= 5;
}
// 168 defensive
dmgbonusmod += (defender->spellbonuses.MeleeMitigationEffect +
defender->itembonuses.MeleeMitigationEffect +
@ -5483,7 +5486,7 @@ void Mob::TrySkillProc(Mob *on, EQ::skills::SkillType skill, uint16 ReuseTime, b
}
}
if (IsClient() && aabonuses.LimitToSkill[skill]) {
if (IsOfClientBot() && aabonuses.LimitToSkill[skill]) {
CanProc = true;
uint32 effect_id = 0;
@ -5797,7 +5800,7 @@ void Mob::CommonOutgoingHitSuccess(Mob* defender, DamageHitInfo &hit, ExtraAttac
TryCriticalHit(defender, hit, opts);
hit.damage_done += hit.min_damage;
if (IsClient() || IsBot()) {
if (IsOfClientBot()) {
int extra = 0;
switch (hit.skill) {
case EQ::skills::SkillThrowing:

View File

@ -57,7 +57,7 @@ int64 Mob::GetActSpellDamage(uint16 spell_id, int64 value, Mob* target) {
value -= (GetLevel() - 40) * 20;
//This adds the extra damage from the AA Unholy Touch, 450 per level to the AA Improved Harm TOuch.
if (spell_id == SPELL_IMP_HARM_TOUCH && (IsClient() || IsBot())) //Improved Harm Touch
if (spell_id == SPELL_IMP_HARM_TOUCH && IsOfClientBot()) //Improved Harm Touch
value -= GetAA(aaUnholyTouch) * 450; //Unholy Touch
chance = RuleI(Spells, BaseCritChance); //Wizard base critical chance is 2% (Does not scale with level)
@ -65,12 +65,12 @@ int64 Mob::GetActSpellDamage(uint16 spell_id, int64 value, Mob* target) {
chance += itembonuses.FrenziedDevastation + spellbonuses.FrenziedDevastation + aabonuses.FrenziedDevastation;
//Crtical Hit Calculation pathway
if (chance > 0 || ((IsClient() || IsBot()) && GetClass() == WIZARD && GetLevel() >= RuleI(Spells, WizCritLevel))) {
if (chance > 0 || (IsOfClientBot() && GetClass() == WIZARD && GetLevel() >= RuleI(Spells, WizCritLevel))) {
int32 ratio = RuleI(Spells, BaseCritRatio); //Critical modifier is applied from spell effects only. Keep at 100 for live like criticals.
//Improved Harm Touch is a guaranteed crit if you have at least one level of SCF.
if (spell_id == SPELL_IMP_HARM_TOUCH && (IsClient() || IsBot()) && (GetAA(aaSpellCastingFury) > 0) && (GetAA(aaUnholyTouch) > 0))
if (spell_id == SPELL_IMP_HARM_TOUCH && IsOfClientBot() && (GetAA(aaSpellCastingFury) > 0) && (GetAA(aaUnholyTouch) > 0))
chance = 100;
if (spells[spell_id].override_crit_chance > 0 && chance > spells[spell_id].override_crit_chance)
@ -82,7 +82,7 @@ int64 Mob::GetActSpellDamage(uint16 spell_id, int64 value, Mob* target) {
ratio += itembonuses.SpellCritDmgIncNoStack + spellbonuses.SpellCritDmgIncNoStack + aabonuses.SpellCritDmgIncNoStack;
}
else if (((IsClient() || IsBot()) && GetClass() == WIZARD) || (IsMerc() && GetClass() == CASTERDPS)) {
else if ((IsOfClientBot() && GetClass() == WIZARD) || (IsMerc() && GetClass() == CASTERDPS)) {
if ((GetLevel() >= RuleI(Spells, WizCritLevel)) && zone->random.Roll(RuleI(Spells, WizCritChance))){
//Wizard innate critical chance is calculated seperately from spell effect and is not a set ratio. (20-70 is parse confirmed)
ratio += zone->random.Int(20,70);
@ -90,7 +90,7 @@ int64 Mob::GetActSpellDamage(uint16 spell_id, int64 value, Mob* target) {
}
}
if ((IsClient() || IsBot()) && GetClass() == WIZARD)
if (IsOfClientBot() && GetClass() == WIZARD)
ratio += RuleI(Spells, WizCritRatio); //Default is zero
if (Critical){

View File

@ -1040,7 +1040,7 @@ int64 Mob::TuneACSum(bool skip_caps, int ac_override, int add_ac)
}
int shield_ac = 0;
if (HasShieldEquiped() && (IsClient() || IsBot())) {
if (HasShieldEquiped() && IsOfClientBot()) {
auto inst = (IsClient()) ? GetInv().GetItem(EQ::invslot::slotSecondary) : CastToBot()->GetBotItem(EQ::invslot::slotSecondary);
if (inst) {
if (inst->GetItemRecommendedLevel(true) <= GetLevel()) {
@ -1348,7 +1348,7 @@ int64 Mob::Tunecompute_defense(int avoidance_override, int add_avoidance)
{
int defense = GetSkill(EQ::skills::SkillDefense) * 400 / 225;
defense += (8000 * (GetAGI() - 40)) / 36000;
if (IsClient() || IsBot()) {
if (IsOfClientBot()) {
if (avoidance_override) {
defense = avoidance_override;
}
@ -1490,7 +1490,7 @@ void Mob::TuneCommonOutgoingHitSuccess(Mob* defender, DamageHitInfo &hit, ExtraA
hit.damage_done = min_mod;
hit.damage_done += hit.min_damage;
if (IsClient() || IsBot()) {
if (IsOfClientBot()) {
int extra = 0;
switch (hit.skill) {
case EQ::skills::SkillThrowing: