From 3c19ab5fde0b110472f666c48ecf514a1fc84866 Mon Sep 17 00:00:00 2001 From: Andrew <47818697+Nyeriah@users.noreply.github.com> Date: Fri, 3 Jan 2025 14:28:56 -0300 Subject: [PATCH] fix(Scripts/ZulAman): Fix Jan'lai teleport spells (#21083) --- .../rev_1735913324331119200.sql | 4 ++ .../EasternKingdoms/ZulAman/boss_janalai.cpp | 42 ++++++++++++++++--- 2 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1735913324331119200.sql diff --git a/data/sql/updates/pending_db_world/rev_1735913324331119200.sql b/data/sql/updates/pending_db_world/rev_1735913324331119200.sql new file mode 100644 index 000000000..8e5c898bb --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1735913324331119200.sql @@ -0,0 +1,4 @@ +-- +DELETE FROM `spell_script_names` WHERE `spell_id` = 43096; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(43096, 'spell_summon_all_players_dummy'); diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp index 401b8f6f5..238e94e1e 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp @@ -21,6 +21,8 @@ #include "GridNotifiersImpl.h" #include "PassiveAI.h" #include "ScriptedCreature.h" +#include "SpellScript.h" +#include "SpellScriptLoader.h" #include "zulaman.h" enum Yells @@ -42,6 +44,7 @@ enum Spells SPELL_FLAME_BREATH = 43140, SPELL_FIRE_WALL = 43113, SPELL_ENRAGE = 44779, + SPELL_SUMMON_PLAYERS_DUMMY = 43096, SPELL_SUMMON_PLAYERS = 43097, SPELL_TELE_TO_CENTER = 43098, // coord SPELL_HATCH_ALL = 43144, @@ -323,11 +326,9 @@ struct boss_janalai : public BossAI SpawnBombs(); _isBombing = true; - me->GetMap()->DoForAllPlayers([&](Player* player) - { - if (player->IsAlive()) - DoTeleportPlayer(player, janalainPos.GetPositionX() - 5 + rand() % 10, janalainPos.GetPositionY() - 5 + rand() % 10, janalainPos.GetPositionZ(), 0.0f); - }); + DoCastSelf(SPELL_TELE_TO_CENTER); + DoCastAOE(SPELL_SUMMON_PLAYERS_DUMMY, true); + //DoCast(Temp, SPELL_SUMMON_PLAYERS, true) // core bug, spell does not work if too far ThrowBombs(); @@ -449,8 +450,39 @@ private: bool _isHatching; }; +class spell_summon_all_players_dummy: public SpellScript +{ + PrepareSpellScript(spell_summon_all_players_dummy); + + bool Validate(SpellInfo const* /*spell*/) override + { + return ValidateSpellInfo({ SPELL_SUMMON_PLAYERS }); + } + + void FilterTargets(std::list& targets) + { + Position pos = GetCaster()->GetPosition(); + targets.remove_if([&, pos](WorldObject* target) -> bool + { + return target->IsWithinBox(pos, 18.0f, 18.0f, 18.0f); + }); + } + + void OnHit(SpellEffIndex /*effIndex*/) + { + GetCaster()->CastSpell(GetHitUnit(), SPELL_SUMMON_PLAYERS, true); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_summon_all_players_dummy::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffectHitTarget += SpellEffectFn(spell_summon_all_players_dummy::OnHit, EFFECT_0, SPELL_EFFECT_DUMMY); + } +}; + void AddSC_boss_janalai() { RegisterZulAmanCreatureAI(boss_janalai); RegisterZulAmanCreatureAI(npc_janalai_hatcher); + RegisterSpellScript(spell_summon_all_players_dummy); }