diff options
| author | avarishd <46330494+avarishd@users.noreply.github.com> | 2023-10-11 02:25:26 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-10 20:25:26 -0300 |
| commit | 5aca484574bdca3cb46aeb6fbc4b6dbac51227ca (patch) | |
| tree | 7d157f025106fd957d5dace64c802c692845ed27 /src/server/scripts/Spells | |
| parent | 99a0d2923a70cc44b6b7dea519c082ac41510790 (diff) | |
fix(Core/Scripts): Venomhide Hatchling improvements (#17454)
Diffstat (limited to 'src/server/scripts/Spells')
| -rw-r--r-- | src/server/scripts/Spells/spell_item.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 17d9156e98..584e389bb2 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -3883,6 +3883,64 @@ class spell_item_worn_troll_dice : public SpellScript } }; +enum VenomhideHatchling +{ + NPC_VENOMHIDE_HATCHLING = 34320 +}; + +class spell_item_venomhide_feed : public SpellScript +{ + PrepareSpellScript(spell_item_venomhide_feed) + + SpellCastResult CheckCast() + { + if (Player* player = GetCaster()->ToPlayer()) + { + std::list<Creature*> hatchling; + player->GetAllMinionsByEntry(hatchling, NPC_VENOMHIDE_HATCHLING); + if (!hatchling.empty()) + { + return SPELL_CAST_OK; + } + } + + return SPELL_FAILED_BAD_TARGETS; + } + + void UpdateTarget(WorldObject*& target) + { + if (!target) + { + return; + } + + if (Player* player = GetCaster()->ToPlayer()) + { + std::list<Creature*> hatchling; + player->GetAllMinionsByEntry(hatchling, NPC_VENOMHIDE_HATCHLING); + if (hatchling.empty()) + { + return; + } + + for (Creature* creature : hatchling) + { + if (creature) + { + target = creature; + return; + } + } + } + } + + void Register() override + { + OnCheckCast += SpellCheckCastFn(spell_item_venomhide_feed::CheckCast); + OnObjectTargetSelect += SpellObjectTargetSelectFn(spell_item_venomhide_feed::UpdateTarget, EFFECT_0, TARGET_UNIT_NEARBY_ENTRY); + } +}; + void AddSC_item_spell_scripts() { RegisterSpellScript(spell_item_massive_seaforium_charge); @@ -4003,4 +4061,5 @@ void AddSC_item_spell_scripts() RegisterSpellScript(spell_item_green_whelp_armor); RegisterSpellScript(spell_item_elixir_of_shadows); RegisterSpellScript(spell_item_worn_troll_dice); + RegisterSpellScript(spell_item_venomhide_feed); } |
