From 6cb85d2ff426d395030674a00678fa7bee8af7a0 Mon Sep 17 00:00:00 2001 From: Skjalf <47818697+Nyeriah@users.noreply.github.com> Date: Fri, 4 Nov 2022 19:17:50 -0300 Subject: [PATCH] =?UTF-8?q?fix(Scripts/TempleOfAhnQiraj):=20Fix=20crash=20?= =?UTF-8?q?caused=20by=20permanently=20spawni=E2=80=A6=20(#13698)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix(Scripts/TempleOfAhnQiraj): Fix crash caused by permanently spawning a tentacle --- .../Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp | 72 ++++++++++--------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp index e5e6fab05..b1d1fc203 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp @@ -602,11 +602,14 @@ struct npc_eye_tentacle : public ScriptedAI portal->SetReactState(REACT_PASSIVE); _portalGUID = portal->GetGUID(); - if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) + if (me->ToTempSummon()) { - if (Creature* creature = summoner->ToCreature()) + if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) { - creature->AI()->JustSummoned(portal); + if (Creature* creature = summoner->ToCreature()) + { + creature->AI()->JustSummoned(portal); + } } } } @@ -673,11 +676,14 @@ struct npc_claw_tentacle : public ScriptedAI portal->SetReactState(REACT_PASSIVE); _portalGUID = portal->GetGUID(); - if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) + if (me->ToTempSummon()) { - if (Creature* creature = summoner->ToCreature()) + if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) { - creature->AI()->JustSummoned(portal); + if (Creature* creature = summoner->ToCreature()) + { + creature->AI()->JustSummoned(portal); + } } } } @@ -740,11 +746,14 @@ struct npc_giant_claw_tentacle : public ScriptedAI portal->SetReactState(REACT_PASSIVE); _portalGUID = portal->GetGUID(); - if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) + if (me->ToTempSummon()) { - if (Creature* creature = summoner->ToCreature()) + if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) { - creature->AI()->JustSummoned(portal); + if (Creature* creature = summoner->ToCreature()) + { + creature->AI()->JustSummoned(portal); + } } } } @@ -771,24 +780,10 @@ struct npc_giant_claw_tentacle : public ScriptedAI void EnterCombat(Unit* /*who*/) override { DoZoneInCombat(); - - _scheduler.Schedule(2s, [this](TaskContext context) - { - DoCastVictim(SPELL_HAMSTRING); - context.Repeat(10s); - }).Schedule(5s, [this](TaskContext context) - { - DoCastSelf(SPELL_THRASH); - context.Repeat(10s); - }).Schedule(3s, [this](TaskContext /*context*/) - { - _canAttack = true; - }); - - ScheduleMeleeCheck(); + ScheduleTasks(); } - void ScheduleMeleeCheck() + void ScheduleTasks() { // Check if a target is in melee range _scheduler.Schedule(10s, [this](TaskContext task) @@ -810,6 +805,17 @@ struct npc_giant_claw_tentacle : public ScriptedAI } task.Repeat(); + }).Schedule(2s, [this](TaskContext context) + { + DoCastVictim(SPELL_HAMSTRING); + context.Repeat(10s); + }).Schedule(5s, [this](TaskContext context) + { + DoCastSelf(SPELL_THRASH); + context.Repeat(10s); + }).Schedule(3s, [this](TaskContext /*context*/) + { + _canAttack = true; }); } @@ -856,13 +862,8 @@ struct npc_giant_claw_tentacle : public ScriptedAI DoCastAOE(SPELL_MASSIVE_GROUND_RUPTURE, true); me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); - ScheduleMeleeCheck(); + ScheduleTasks(); } - - _scheduler.Schedule(3s, [this](TaskContext /*context*/) - { - _canAttack = true; - }); } void UpdateAI(uint32 diff) override @@ -896,11 +897,14 @@ struct npc_giant_eye_tentacle : public ScriptedAI portal->SetReactState(REACT_PASSIVE); _portalGUID = portal->GetGUID(); - if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) + if (me->ToTempSummon()) { - if (Creature* creature = summoner->ToCreature()) + if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) { - creature->AI()->JustSummoned(portal); + if (Creature* creature = summoner->ToCreature()) + { + creature->AI()->JustSummoned(portal); + } } } }