From 621d951551c6b2331ef7882bb6f4156e1bffb515 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Wed, 25 Oct 2023 01:50:26 +0200 Subject: [PATCH] Scripts/Totems: scripted Shaman's Searing Totem behavior --- .../Creature/TemporarySummon/NewPet.cpp | 7 --- src/server/scripts/World/npcs_special.cpp | 53 +++++++++++++++++++ 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/src/server/game/Entities/Creature/TemporarySummon/NewPet.cpp b/src/server/game/Entities/Creature/TemporarySummon/NewPet.cpp index 13e0653ade..fa58304176 100644 --- a/src/server/game/Entities/Creature/TemporarySummon/NewPet.cpp +++ b/src/server/game/Entities/Creature/TemporarySummon/NewPet.cpp @@ -763,13 +763,6 @@ bool NewPet::AddSpell(uint32 spellId, ActiveStates active /*= ACT_DECIDE*/, PetS } } - // Store pet scaling auras in a own vector to handle the updating more efficient - //if (spellInfo->HasAttribute(SPELL_ATTR4_OWNER_POWER_SCALING)) - //{ - // m_petScalingAuras.push_back(spellInfo->Id); - // return true; - //} - _spells[spellId] = newspell; if (spellInfo->IsPassive() && (!spellInfo->CasterAuraState || HasAuraState(AuraStateType(spellInfo->CasterAuraState)))) diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index 626c946b4c..aa6bd0076b 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -3075,6 +3075,58 @@ struct npc_shaman_spirit_wolf : public PetAI } }; +struct npc_shaman_searing_totem : public NullCreatureAI +{ + npc_shaman_searing_totem(Creature* creature) : NullCreatureAI(creature) { } + + static constexpr uint32 SPELL_SEARING_BOLT = 3606; + + void JustAppeared() override + { + _scheduler.Schedule(1ms, [this](TaskContext context) + { + context.Repeat(1s + 600ms); + + // The Searing Totem prefers targets afflicted by its creator's Flameshock and Stormstrike ability + std::list targets; + Trinity::NearestAttackableUnitInObjectRangeCheck u_check(me, me->GetCreator(), 15.f); + Trinity::UnitListSearcher searcher(me, targets, u_check); + Cell::VisitAllObjects(me, searcher, 15.f); + targets.sort(Trinity::ObjectDistanceOrderPred(me)); + + if (targets.empty()) + return; + + Unit* target = targets.front(); + + targets.remove_if([creatorGuid = me->GetCreatorGUID()](Unit const* target) + { + if (target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_SHAMAN, 0x10000000, 0x0, 0x0, creatorGuid)) + return false; + + if (target->GetAuraEffect(SPELL_AURA_MOD_CRIT_CHANCE_FOR_CASTER, SPELLFAMILY_SHAMAN, 0x0, 0x1000000, 0x0, creatorGuid)) + return false; + + return true; + }); + + if (!targets.empty()) + target = targets.front(); + + if (target) + me->CastSpell(target, SPELL_SEARING_BOLT); + }); + } + + void UpdateAI(uint32 diff) override + { + _scheduler.Update(diff); + } + +private: + TaskScheduler _scheduler; +}; + void AddSC_npcs_special() { new npc_air_force_bots(); @@ -3105,4 +3157,5 @@ void AddSC_npcs_special() RegisterCreatureAI(npc_druid_wild_mushroom); RegisterCreatureAI(npc_darkmoon_island_gnoll); RegisterCreatureAI(npc_shaman_spirit_wolf); + RegisterCreatureAI(npc_shaman_searing_totem); }