Core/Scripts: Fixed Suppresser behavior in Valithria Dreamwalker encounter

Closes #18530
* Fixed range issue
* Fixed weave spawn when Summon Timmer Suppresser(70912) is casted
* Fixed spawn count
(cherry picked from commit dbd567799f)
This commit is contained in:
Keader
2016-12-22 17:40:24 -03:00
committed by DoctorKraft
parent fd6bcdce98
commit f80d80401b
2 changed files with 42 additions and 20 deletions

View File

@@ -141,11 +141,12 @@ enum Events
EVENT_EXPLODE = 18,
};
enum Actions
enum Misc
{
ACTION_ENTER_COMBAT = 1,
MISSED_PORTALS = 2,
ACTION_DEATH = 3,
ACTION_ENTER_COMBAT = 1,
MISSED_PORTALS = 2,
ACTION_DEATH = 3,
DATA_SUPPRESSERS_COUNT = 4
};
Position const ValithriaSpawnPos = {4210.813f, 2484.443f, 364.9558f, 0.01745329f};
@@ -182,7 +183,7 @@ class DelayedCastEvent : public BasicEvent
bool Execute(uint64 /*time*/, uint32 /*diff*/) override
{
_trigger->CastSpell(_trigger, _spellId, false, NULL, NULL, _originalCaster);
_trigger->CastSpell(_trigger, _spellId, false, nullptr, nullptr, _originalCaster);
if (_despawnTime)
_trigger->DespawnOrUnsummon(_despawnTime);
return true;
@@ -625,6 +626,14 @@ class npc_the_lich_king_controller : public CreatureScript
me->setActive(true);
}
uint32 GetData(uint32 data) const override
{
if (data == DATA_SUPPRESSERS_COUNT)
return RAID_MODE<uint32>(4, 6, 4, 6);
else
return 0;
}
void JustSummoned(Creature* summon) override
{
// must not be in dream phase
@@ -1092,7 +1101,7 @@ class npc_dream_cloud : public CreatureScript
{
case EVENT_CHECK_PLAYER:
{
Player* player = NULL;
Player* player = nullptr;
Trinity::AnyPlayerInObjectRangeCheck check(me, 5.0f);
Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(me, player, check);
Cell::VisitWorldObjects(me, searcher, 7.5f);
@@ -1102,7 +1111,7 @@ class npc_dream_cloud : public CreatureScript
case EVENT_EXPLODE:
me->GetMotionMaster()->MoveIdle();
// must use originalCaster the same for all clouds to allow stacking
me->CastSpell(me, EMERALD_VIGOR, false, NULL, NULL, _instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER));
me->CastSpell(me, EMERALD_VIGOR, false, nullptr, nullptr, _instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER));
me->DespawnOrUnsummon(100);
break;
default:
@@ -1230,7 +1239,7 @@ class spell_dreamwalker_summoner : public SpellScriptLoader
if (!GetHitUnit())
return;
GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, true, NULL, NULL, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING));
GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, true, nullptr, nullptr, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING));
}
void Register() override
@@ -1255,29 +1264,41 @@ class spell_dreamwalker_summon_suppresser : public SpellScriptLoader
{
PrepareAuraScript(spell_dreamwalker_summon_suppresser_AuraScript);
bool Validate(SpellInfo const* /*spell*/) override
{
return ValidateSpellInfo({ SPELL_SUMMON_SUPPRESSER });
}
void PeriodicTick(AuraEffect const* /*aurEff*/)
{
PreventDefaultAction();
Unit* caster = GetCaster();
if (!caster)
HandleSummon(GetCaster());
}
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
HandleSummon(GetCaster());
}
void HandleSummon(Unit* caster)
{
if (!caster || !caster->IsAIEnabled)
return;
std::list<Creature*> summoners;
GetCreatureListWithEntryInGrid(summoners, caster, NPC_WORLD_TRIGGER, 100.0f);
summoners.remove_if(Trinity::UnitAuraCheck(true, SPELL_RECENTLY_SPAWNED));
Trinity::Containers::RandomResize(summoners, 2);
GetCreatureListWithEntryInGrid(summoners, caster, NPC_WORLD_TRIGGER, 90.0f);
if (summoners.empty())
return;
for (uint32 i = 0; i < 3; ++i)
caster->CastSpell(summoners.front(), SPELL_SUMMON_SUPPRESSER, true);
for (uint32 i = 0; i < 3; ++i)
caster->CastSpell(summoners.back(), SPELL_SUMMON_SUPPRESSER, true);
uint8 suppresserNumber = caster->GetAI()->GetData(DATA_SUPPRESSERS_COUNT);
for (uint8 i = 0; i < suppresserNumber; ++i)
caster->CastSpell(Trinity::Containers::SelectRandomContainerElement(summoners), SPELL_SUMMON_SUPPRESSER, true);
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_dreamwalker_summon_suppresser_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
AfterEffectApply += AuraEffectApplyFn(spell_dreamwalker_summon_suppresser_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
}
};
@@ -1309,7 +1330,7 @@ class spell_dreamwalker_summon_suppresser_effect : public SpellScriptLoader
if (!GetHitUnit())
return;
GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, true, NULL, NULL, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING));
GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, true, nullptr, nullptr, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING));
}
void Register() override
@@ -1405,7 +1426,7 @@ class spell_dreamwalker_nightmare_cloud : public SpellScriptLoader
bool Load() override
{
_instance = GetOwner()->GetInstanceScript();
return _instance != NULL;
return _instance != nullptr;
}
void PeriodicTick(AuraEffect const* /*aurEff*/)
@@ -1445,7 +1466,7 @@ class spell_dreamwalker_twisted_nightmares : public SpellScriptLoader
// return;
if (InstanceScript* instance = GetHitUnit()->GetInstanceScript())
GetHitUnit()->CastSpell((Unit*)NULL, GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, true, NULL, NULL, instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER));
GetHitUnit()->CastSpell((Unit*)nullptr, GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, true, nullptr, nullptr, instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER));
}
void Register() override