fix(Scripts/TempleOfAhnQiraj): Fix crash caused by permanently spawni… (#13698)

fix(Scripts/TempleOfAhnQiraj): Fix crash caused by permanently spawning a tentacle
This commit is contained in:
Skjalf
2022-11-04 19:17:50 -03:00
committed by GitHub
parent fc914f03f1
commit 6cb85d2ff4
@@ -602,6 +602,8 @@ struct npc_eye_tentacle : public ScriptedAI
portal->SetReactState(REACT_PASSIVE); portal->SetReactState(REACT_PASSIVE);
_portalGUID = portal->GetGUID(); _portalGUID = portal->GetGUID();
if (me->ToTempSummon())
{
if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
{ {
if (Creature* creature = summoner->ToCreature()) if (Creature* creature = summoner->ToCreature())
@@ -610,6 +612,7 @@ struct npc_eye_tentacle : public ScriptedAI
} }
} }
} }
}
SetCombatMovement(false); SetCombatMovement(false);
} }
@@ -673,6 +676,8 @@ struct npc_claw_tentacle : public ScriptedAI
portal->SetReactState(REACT_PASSIVE); portal->SetReactState(REACT_PASSIVE);
_portalGUID = portal->GetGUID(); _portalGUID = portal->GetGUID();
if (me->ToTempSummon())
{
if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
{ {
if (Creature* creature = summoner->ToCreature()) if (Creature* creature = summoner->ToCreature())
@@ -682,6 +687,7 @@ struct npc_claw_tentacle : public ScriptedAI
} }
} }
} }
}
void JustDied(Unit* /*killer*/) override void JustDied(Unit* /*killer*/) override
{ {
@@ -740,6 +746,8 @@ struct npc_giant_claw_tentacle : public ScriptedAI
portal->SetReactState(REACT_PASSIVE); portal->SetReactState(REACT_PASSIVE);
_portalGUID = portal->GetGUID(); _portalGUID = portal->GetGUID();
if (me->ToTempSummon())
{
if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
{ {
if (Creature* creature = summoner->ToCreature()) if (Creature* creature = summoner->ToCreature())
@@ -748,6 +756,7 @@ struct npc_giant_claw_tentacle : public ScriptedAI
} }
} }
} }
}
_canAttack = false; _canAttack = false;
} }
@@ -771,24 +780,10 @@ struct npc_giant_claw_tentacle : public ScriptedAI
void EnterCombat(Unit* /*who*/) override void EnterCombat(Unit* /*who*/) override
{ {
DoZoneInCombat(); DoZoneInCombat();
ScheduleTasks();
_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();
} }
void ScheduleMeleeCheck() void ScheduleTasks()
{ {
// Check if a target is in melee range // Check if a target is in melee range
_scheduler.Schedule(10s, [this](TaskContext task) _scheduler.Schedule(10s, [this](TaskContext task)
@@ -810,6 +805,17 @@ struct npc_giant_claw_tentacle : public ScriptedAI
} }
task.Repeat(); 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); DoCastAOE(SPELL_MASSIVE_GROUND_RUPTURE, true);
me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); 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 void UpdateAI(uint32 diff) override
@@ -896,6 +897,8 @@ struct npc_giant_eye_tentacle : public ScriptedAI
portal->SetReactState(REACT_PASSIVE); portal->SetReactState(REACT_PASSIVE);
_portalGUID = portal->GetGUID(); _portalGUID = portal->GetGUID();
if (me->ToTempSummon())
{
if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
{ {
if (Creature* creature = summoner->ToCreature()) if (Creature* creature = summoner->ToCreature())
@@ -905,6 +908,7 @@ struct npc_giant_eye_tentacle : public ScriptedAI
} }
} }
} }
}
void JustDied(Unit* /*killer*/) override void JustDied(Unit* /*killer*/) override
{ {