fix(Scripts/SSC): make sure Insidious Whispers demons don't instantly despawn (#17672)

* initial commit

* reset threat list

threat should drop on any phase transition
This commit is contained in:
Dan
2023-11-11 19:00:52 +01:00
committed by GitHub
parent 8d2f0afbe6
commit 8f81a08455
@@ -100,12 +100,11 @@ struct boss_leotheras_the_blind : public BossAI
if (me->GetDisplayId() != me->GetNativeDisplayId()) if (me->GetDisplayId() != me->GetNativeDisplayId())
{ {
//is currently in metamorphosis //is currently in metamorphosis
DoResetThreatList();
me->LoadEquipment(); me->LoadEquipment();
me->RemoveAurasDueToSpell(SPELL_METAMORPHOSIS); me->RemoveAurasDueToSpell(SPELL_METAMORPHOSIS);
scheduler.RescheduleGroup(GROUP_COMBAT, 10s); scheduler.RescheduleGroup(GROUP_COMBAT, 10s);
} }
DoResetThreatList();
scheduler.CancelGroup(GROUP_DEMON); scheduler.CancelGroup(GROUP_DEMON);
scheduler.DelayAll(10s); scheduler.DelayAll(10s);
@@ -172,6 +171,8 @@ struct boss_leotheras_the_blind : public BossAI
void ElfTime() void ElfTime()
{ {
DoResetThreatList();
me->InterruptNonMeleeSpells(false);
scheduler.Schedule(25050ms, 32550ms, GROUP_COMBAT, [this](TaskContext context) scheduler.Schedule(25050ms, 32550ms, GROUP_COMBAT, [this](TaskContext context)
{ {
DoCastSelf(SPELL_WHIRLWIND); DoCastSelf(SPELL_WHIRLWIND);
@@ -186,6 +187,8 @@ struct boss_leotheras_the_blind : public BossAI
void DemonTime() void DemonTime()
{ {
DoResetThreatList();
me->InterruptNonMeleeSpells(false);
me->LoadEquipment(0, true); me->LoadEquipment(0, true);
me->GetMotionMaster()->MoveChase(me->GetVictim(), 25.0f); me->GetMotionMaster()->MoveChase(me->GetVictim(), 25.0f);
DoCastSelf(SPELL_METAMORPHOSIS, true); DoCastSelf(SPELL_METAMORPHOSIS, true);
@@ -240,16 +243,18 @@ struct npc_inner_demon : public ScriptedAI
_instance = creature->GetInstanceScript(); _instance = creature->GetInstanceScript();
} }
void EnterEvadeMode(EvadeReason /*why*/) override
{
me->DespawnOrUnsummon(1);
}
void IsSummonedBy(WorldObject* summoner) override void IsSummonedBy(WorldObject* summoner) override
{ {
if (!summoner) if (!summoner)
return; return;
//summoner is always the affected player
_affectedPlayerGUID = summoner->GetGUID();
if (Unit* affectedPlayer = summoner->ToUnit())
{
me->Attack(affectedPlayer, true);
}
_scheduler.CancelAll(); _scheduler.CancelAll();
_scheduler.Schedule(4s, [this](TaskContext context) _scheduler.Schedule(4s, [this](TaskContext context)
{ {
@@ -260,30 +265,23 @@ struct npc_inner_demon : public ScriptedAI
void JustDied(Unit* /*killer*/) override void JustDied(Unit* /*killer*/) override
{ {
if (Creature* leotheras = _instance->GetCreature(DATA_LEOTHERAS_THE_BLIND)) if (Unit* affectedPlayer = ObjectAccessor::GetUnit(*me, _affectedPlayerGUID))
{ {
leotheras->RemoveAurasDueToSpell(SPELL_INSIDIOUS_WHISPER); affectedPlayer->RemoveAurasDueToSpell(SPELL_INSIDIOUS_WHISPER);
} }
} }
void DamageTaken(Unit* who, uint32& damage, DamageEffectType, SpellSchoolMask) override void DamageTaken(Unit* who, uint32& damage, DamageEffectType, SpellSchoolMask) override
{ {
if (Creature* leotheras = _instance->GetCreature(DATA_LEOTHERAS_THE_BLIND)) if (!who || who->GetGUID() != _affectedPlayerGUID)
{ {
if (!who || who->GetGUID() != leotheras->GetGUID()) damage = 0;
{
damage = 0;
}
} }
} }
bool CanAIAttack(Unit const* who) const override bool CanAIAttack(Unit const* who) const override
{ {
if (Creature* leotheras = _instance->GetCreature(DATA_LEOTHERAS_THE_BLIND)) return who->GetGUID() == _affectedPlayerGUID;
{
return who->GetGUID() == leotheras->GetGUID();
}
return false;
} }
void UpdateAI(uint32 diff) override void UpdateAI(uint32 diff) override
@@ -300,6 +298,7 @@ struct npc_inner_demon : public ScriptedAI
private: private:
TaskScheduler _scheduler; TaskScheduler _scheduler;
InstanceScript* _instance; InstanceScript* _instance;
ObjectGuid _affectedPlayerGUID;
}; };
class spell_leotheras_whirlwind : public SpellScriptLoader class spell_leotheras_whirlwind : public SpellScriptLoader
@@ -373,7 +372,9 @@ public:
void FilterTargets(std::list<WorldObject*>& unitList) void FilterTargets(std::list<WorldObject*>& unitList)
{ {
if (Unit* victim = GetCaster()->GetVictim()) if (Unit* victim = GetCaster()->GetVictim())
{
unitList.remove_if(Acore::ObjectGUIDCheck(victim->GetGUID(), true)); unitList.remove_if(Acore::ObjectGUIDCheck(victim->GetGUID(), true));
}
} }
void Register() override void Register() override
@@ -399,9 +400,15 @@ public:
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEFAULT) if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEFAULT)
{
if (InstanceScript* instance = GetUnitOwner()->GetInstanceScript()) if (InstanceScript* instance = GetUnitOwner()->GetInstanceScript())
if (Creature* leotheras = ObjectAccessor::GetCreature(*GetUnitOwner(), instance->GetGuidData(NPC_LEOTHERAS_THE_BLIND))) {
if (Creature* leotheras = instance->GetCreature(DATA_LEOTHERAS_THE_BLIND))
{
leotheras->CastSpell(GetUnitOwner(), SPELL_CONSUMING_MADNESS, true); leotheras->CastSpell(GetUnitOwner(), SPELL_CONSUMING_MADNESS, true);
}
}
}
} }
void Register() override void Register() override
@@ -430,7 +437,9 @@ public:
{ {
PreventDefaultAction(); PreventDefaultAction();
if (Unit* victim = GetUnitOwner()->GetVictim()) if (Unit* victim = GetUnitOwner()->GetVictim())
{
GetUnitOwner()->CastSpell(victim, GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell, true); GetUnitOwner()->CastSpell(victim, GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell, true);
}
} }
void Register() override void Register() override
@@ -458,7 +467,9 @@ public:
{ {
PreventHitDefaultEffect(effIndex); PreventHitDefaultEffect(effIndex);
if (Unit* target = GetHitUnit()) if (Unit* target = GetHitUnit())
{
Unit::Kill(GetCaster(), target); Unit::Kill(GetCaster(), target);
}
} }
void Register() override void Register() override