From a8a3011278487f1e10017d082ceaa3f44a4e69b8 Mon Sep 17 00:00:00 2001 From: Timothy Vaccarelli Date: Wed, 12 Apr 2023 07:07:00 -0400 Subject: [PATCH] fix(Script/Spell): Fix animal blood pool effect and position (#15918) Adapted from TC Commits 3ddc6e70df0401a0677bef536e6b0e46e3dbf9e9 and cc3293c0023b36434747190103a1f0ffee0f8488 Co-authored-by: sirikfoll Co-authored-by: Rushor --- .../rev_1681232229972193910.sql | 5 ++++ src/server/scripts/Spells/spell_generic.cpp | 25 +++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1681232229972193910.sql diff --git a/data/sql/updates/pending_db_world/rev_1681232229972193910.sql b/data/sql/updates/pending_db_world/rev_1681232229972193910.sql new file mode 100644 index 000000000..6ff94cfb7 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1681232229972193910.sql @@ -0,0 +1,5 @@ +-- Add spell script to database for 63471 - Spawn Blood Pool +DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_spawn_blood_pool'; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(63471, 'spell_spawn_blood_pool'); + diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index ac326f538..e4acbc9a1 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -2030,8 +2030,7 @@ class spell_gen_animal_blood : public AuraScript { if (Unit* owner = GetUnitOwner()) { - if (owner->IsInWater()) - owner->CastSpell(owner, SPELL_SPAWN_BLOOD_POOL, true); + owner->CastSpell(owner, SPELL_SPAWN_BLOOD_POOL, true); } } @@ -2042,6 +2041,27 @@ class spell_gen_animal_blood : public AuraScript } }; +// 63471 - Spawn Blood Pool +class spell_spawn_blood_pool : public SpellScript +{ + PrepareSpellScript(spell_spawn_blood_pool); + + void SetDest(SpellDestination &dest) + { + Unit* caster = GetCaster(); + LiquidData liquidStatus = caster->GetMap()->GetLiquidData(caster->GetPhaseMask(), caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ(), caster->GetCollisionHeight(), MAP_ALL_LIQUIDS); + + float level = liquidStatus.Level > INVALID_HEIGHT ? liquidStatus.Level : caster->GetPositionZ(); + Position pos = Position(caster->GetPositionX(), caster->GetPositionY(), level, caster->GetOrientation()); + dest.Relocate(pos); + } + + void Register() override + { + OnDestinationTargetSelect += SpellDestinationTargetSelectFn(spell_spawn_blood_pool::SetDest, EFFECT_0, TARGET_DEST_CASTER); + } +}; + enum DivineStormSpell { SPELL_DIVINE_STORM = 53385, @@ -4893,6 +4913,7 @@ void AddSC_generic_spell_scripts() RegisterSpellScript(spell_gen_feign_death_no_prevent_emotes); RegisterSpellScript(spell_pvp_trinket_wotf_shared_cd); RegisterSpellScript(spell_gen_animal_blood); + RegisterSpellScript(spell_spawn_blood_pool); RegisterSpellScript(spell_gen_divine_storm_cd_reset); RegisterSpellScript(spell_gen_profession_research); RegisterSpellScript(spell_gen_clone);