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); + } } } }