From a16f21d6fee69c053ae9c5d626cf332cf084ac3e Mon Sep 17 00:00:00 2001 From: Aeadoin <109764533+Aeadoin@users.noreply.github.com> Date: Thu, 19 Jan 2023 23:45:09 -0500 Subject: [PATCH] [Bots] Add Support for AA bonuses that were missing. (#2764) * [Bots] Add Support for AA bonuses that were missing. * Fix GetFocusEffect, add virtual override to Bot to prevent using NPC --- zone/attack.cpp | 10 +++++----- zone/bot.h | 2 ++ zone/mob.cpp | 21 ++++++++++----------- zone/spell_effects.cpp | 19 +++++++++++-------- zone/spells.cpp | 18 ++++++++---------- 5 files changed, 36 insertions(+), 34 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index b39759a1f..ec0a89d0a 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -3544,7 +3544,7 @@ bool Mob::HasProcs() const } } - if (IsClient()) { + if (IsClient() || IsBot()) { for (int i = 0; i < MAX_AA_PROCS; i += 4) { if (aabonuses.SpellProc[i]) { return true; @@ -3562,7 +3562,7 @@ bool Mob::HasDefensiveProcs() const } } - if (IsClient()) { + if (IsClient() || IsBot()) { for (int i = 0; i < MAX_AA_PROCS; i += 4) { if (aabonuses.DefensiveProc[i]) { return true; @@ -3598,7 +3598,7 @@ bool Mob::HasRangedProcs() const } } - if (IsClient()) { + if (IsClient() || IsBot()) { for (int i = 0; i < MAX_AA_PROCS; i += 4) { if (aabonuses.RangedProc[i]) { return true; @@ -4367,7 +4367,7 @@ void Mob::TryDefensiveProc(Mob *on, uint16 hand) { } //AA Procs - if (IsClient()){ + if (IsClient() || IsBot()){ 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]; @@ -4625,7 +4625,7 @@ void Mob::TrySpellProc(const EQ::ItemInstance *inst, const EQ::ItemData *weapon, } //AA Melee and Ranged Procs - if (IsClient()) { + if (IsClient() || IsBot()) { for (int i = 0; i < MAX_AA_PROCS; i += 4) { int32 aa_rank_id = 0; diff --git a/zone/bot.h b/zone/bot.h index e13d8e97c..1d13a9797 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -374,6 +374,8 @@ public: virtual bool DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_center, CastAction_type &CastAction, EQ::spells::CastingSlot slot); virtual bool DoCastSpell(uint16 spell_id, uint16 target_id, EQ::spells::CastingSlot slot = EQ::spells::CastingSlot::Item, int32 casttime = -1, int32 mana_cost = -1, uint32* oSpellWillFinish = 0, uint32 item_slot = 0xFFFFFFFF, uint32 aa_id = 0); + inline int64 GetFocusEffect(focusType type, uint16 spell_id, Mob *caster = nullptr, bool from_buff_tic = false) override + { return Mob::GetFocusEffect(type, spell_id, caster, from_buff_tic); } bool GetBotOwnerDataBuckets(); bool GetBotDataBuckets(); diff --git a/zone/mob.cpp b/zone/mob.cpp index 0b7e88caf..65c637227 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -3261,10 +3261,6 @@ const int64& Mob::SetMana(int64 amount) CalcMaxMana(); int64 mmana = GetMaxMana(); current_mana = amount < 0 ? 0 : (amount > mmana ? mmana : amount); -/* - if(IsClient()) - LogFile->write(EQEMuLog::Debug, "Setting mana for %s to %d (%4.1f%%)", GetName(), amount, GetManaRatio()); -*/ return current_mana; } @@ -4162,8 +4158,8 @@ void Mob::ExecWeaponProc(const EQ::ItemInstance *inst, uint16 spell_id, Mob *on, bool twinproc = false; int32 twinproc_chance = 0; - if (IsClient()) { - twinproc_chance = CastToClient()->GetFocusEffect(focusTwincast, spell_id); + if (IsClient() || IsBot()) { + twinproc_chance = GetFocusEffect(focusTwincast, spell_id); } if (twinproc_chance && zone->random.Roll(twinproc_chance)) { @@ -4642,18 +4638,21 @@ void Mob::TryTriggerOnCastRequirement() //Twincast Focus effects should stack across different types (Spell, AA - when implemented ect) void Mob::TryTwincast(Mob *caster, Mob *target, uint32 spell_id) { - if(!IsValidSpell(spell_id)) + if (!IsValidSpell(spell_id)) { return; + } - if(IsClient()) + if (IsClient() || IsBot()) { - int focus = CastToClient()->GetFocusEffect(focusTwincast, spell_id); + int focus = GetFocusEffect(focusTwincast, spell_id); if (focus > 0) { - if(zone->random.Roll(focus)) + if (zone->random.Roll(focus)) { - Message(Chat::Spells,"You twincast %s!", spells[spell_id].name); + if (IsClient()) { + Message(Chat::Spells,"You twincast %s!", spells[spell_id].name); + } SpellFinished(spell_id, target, EQ::spells::CastingSlot::Item, 0, -1, spells[spell_id].resist_difficulty); } } diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index df957cec6..81b5eced7 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -717,14 +717,16 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove caster->MessageString(Chat::SpellFailure, IMMUNE_STUN); } else { int stun_resist = itembonuses.StunResist+spellbonuses.StunResist; - if (IsClient()) + if (IsClient() || IsBot()) { stun_resist += aabonuses.StunResist; + } if (stun_resist <= 0 || zone->random.Int(0,99) >= stun_resist) { LogCombat("Stunned. We had [{}] percent resist chance", stun_resist); - if (caster && caster->IsClient()) + if (caster && (caster->IsClient() || caster->IsBot())) { effect_value += effect_value*caster->GetFocusEffect(focusFcStunTimeMod, spell_id)/100; + } Stun(effect_value); } else { @@ -807,7 +809,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove buffs[buffslot].ticsremaining = resistMod * buffs[buffslot].ticsremaining / 100; } - if(IsClient()) + if (IsClient() || IsBot()) { if(buffs[buffslot].ticsremaining > RuleI(Character, MaxCharmDurationForPlayerCharacter)) buffs[buffslot].ticsremaining = RuleI(Character, MaxCharmDurationForPlayerCharacter); @@ -865,21 +867,22 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove #ifdef SPELL_EFFECT_SPAM snprintf(effect_desc, _EDLEN, "Fear: %+i", effect_value); #endif - if(IsClient()) + if (IsClient() || IsBot()) { - if(buffs[buffslot].ticsremaining > RuleI(Character, MaxFearDurationForPlayerCharacter)) + if (buffs[buffslot].ticsremaining > RuleI(Character, MaxFearDurationForPlayerCharacter)) { buffs[buffslot].ticsremaining = RuleI(Character, MaxFearDurationForPlayerCharacter); + } } - if(RuleB(Combat, EnableFearPathing)){ - if(IsClient()) + if (RuleB(Combat, EnableFearPathing)) { + if (IsClient()) { CastToClient()->AI_Start(); } CalculateNewFearpoint(); - if(currently_fleeing) + if (currently_fleeing) { break; } diff --git a/zone/spells.cpp b/zone/spells.cpp index 4bfa40394..ca8880b4d 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -5199,30 +5199,28 @@ int16 Mob::CalcResistChanceBonus() { int resistchance = spellbonuses.ResistSpellChance + itembonuses.ResistSpellChance; - if(IsClient()) + if (IsClient() || IsBot()) { resistchance += aabonuses.ResistSpellChance; - + } return resistchance; } int16 Mob::CalcFearResistChance() { int resistchance = spellbonuses.ResistFearChance + itembonuses.ResistFearChance; - if(IsClient()) { + if (IsClient() || IsBot()) { resistchance += aabonuses.ResistFearChance; - if(aabonuses.Fearless == true) + if (aabonuses.Fearless == true) { resistchance = 100; + } } - if(spellbonuses.Fearless == true || itembonuses.Fearless == true) + if (spellbonuses.Fearless == true || itembonuses.Fearless == true) { resistchance = 100; + } return resistchance; } -/** - * @param spell_id - * @return - */ float Mob::GetAOERange(uint16 spell_id) { float range = spells[spell_id].aoe_range; @@ -5941,7 +5939,7 @@ bool Mob::IsCombatProc(uint16 spell_id) { } } - if (IsClient()) { + if (IsClient() || IsBot()) { for (int i = 0; i < MAX_AA_PROCS; i += 4) { if (aabonuses.SpellProc[i + 1] == spell_id || aabonuses.RangedProc[i + 1] == spell_id ||