mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Scripts/ICC: little bit of cleanup in Valithria after the "recent" changes
(cherry picked from commit 7ffe018571)
This commit is contained in:
@@ -87,11 +87,10 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= nullptr*/)
|
||||
return;
|
||||
}
|
||||
|
||||
Map::PlayerList const& playerList = map->GetPlayers();
|
||||
if (playerList.isEmpty())
|
||||
if (!map->HavePlayers())
|
||||
return;
|
||||
|
||||
for (auto const& ref : playerList)
|
||||
for (MapReference const& ref : map->GetPlayers())
|
||||
{
|
||||
if (Player* player = ref.GetSource())
|
||||
{
|
||||
|
||||
@@ -141,6 +141,15 @@ void CombatManager::Update(uint32 tdiff)
|
||||
}
|
||||
}
|
||||
|
||||
bool CombatManager::HasPvECombatWithPlayers() const
|
||||
{
|
||||
for (std::pair<ObjectGuid const, CombatReference*> const& reference : _pveRefs)
|
||||
if (reference.second->GetOther(_owner)->GetTypeId() == TYPEID_PLAYER)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CombatManager::HasPvPCombat() const
|
||||
{
|
||||
for (auto const& pair : _pvpRefs)
|
||||
|
||||
@@ -106,6 +106,7 @@ class TC_GAME_API CombatManager
|
||||
Unit* GetOwner() const { return _owner; }
|
||||
bool HasCombat() const { return HasPvECombat() || HasPvPCombat(); }
|
||||
bool HasPvECombat() const { return !_pveRefs.empty(); }
|
||||
bool HasPvECombatWithPlayers() const;
|
||||
std::unordered_map<ObjectGuid, CombatReference*> const& GetPvECombatRefs() const { return _pveRefs; }
|
||||
bool HasPvPCombat() const;
|
||||
std::unordered_map<ObjectGuid, PvPCombatReference*> const& GetPvPCombatRefs() const { return _pvpRefs; }
|
||||
|
||||
@@ -111,37 +111,37 @@ enum Spells
|
||||
enum Events
|
||||
{
|
||||
// Valithria Dreamwalker
|
||||
EVENT_INTRO_TALK = 1,
|
||||
EVENT_BERSERK = 2,
|
||||
EVENT_DREAM_PORTAL = 3,
|
||||
EVENT_DREAM_SLIP = 4,
|
||||
EVENT_INTRO_TALK = 1,
|
||||
EVENT_BERSERK,
|
||||
EVENT_DREAM_PORTAL,
|
||||
EVENT_DREAM_SLIP,
|
||||
|
||||
// The Lich King
|
||||
EVENT_GLUTTONOUS_ABOMINATION_SUMMONER = 5,
|
||||
EVENT_SUPPRESSER_SUMMONER = 6,
|
||||
EVENT_BLISTERING_ZOMBIE_SUMMONER = 7,
|
||||
EVENT_RISEN_ARCHMAGE_SUMMONER = 8,
|
||||
EVENT_BLAZING_SKELETON_SUMMONER = 9,
|
||||
EVENT_GLUTTONOUS_ABOMINATION_SUMMONER,
|
||||
EVENT_SUPPRESSER_SUMMONER,
|
||||
EVENT_BLISTERING_ZOMBIE_SUMMONER,
|
||||
EVENT_RISEN_ARCHMAGE_SUMMONER,
|
||||
EVENT_BLAZING_SKELETON_SUMMONER,
|
||||
|
||||
// Risen Archmage
|
||||
EVENT_FROSTBOLT_VOLLEY = 10,
|
||||
EVENT_MANA_VOID = 11,
|
||||
EVENT_COLUMN_OF_FROST = 12,
|
||||
EVENT_FROSTBOLT_VOLLEY,
|
||||
EVENT_MANA_VOID,
|
||||
EVENT_COLUMN_OF_FROST,
|
||||
|
||||
// Blazing Skeleton
|
||||
EVENT_FIREBALL = 13,
|
||||
EVENT_LEY_WASTE = 14,
|
||||
EVENT_FIREBALL,
|
||||
EVENT_LEY_WASTE,
|
||||
|
||||
// Suppresser
|
||||
EVENT_SUPPRESSION = 15,
|
||||
EVENT_SUPPRESSION,
|
||||
|
||||
// Gluttonous Abomination
|
||||
EVENT_GUT_SPRAY = 16,
|
||||
EVENT_GUT_SPRAY,
|
||||
|
||||
// Dream Cloud
|
||||
// Nightmare Cloud
|
||||
EVENT_CHECK_PLAYER = 17,
|
||||
EVENT_EXPLODE = 18,
|
||||
EVENT_CHECK_PLAYER,
|
||||
EVENT_EXPLODE,
|
||||
};
|
||||
|
||||
enum Misc
|
||||
@@ -159,9 +159,11 @@ enum Misc
|
||||
|
||||
Position const ValithriaSpawnPos = {4210.813f, 2484.443f, 364.9558f, 0.01745329f};
|
||||
|
||||
struct ManaVoidSelector
|
||||
struct ValithriaManaVoidSelector
|
||||
{
|
||||
explicit ManaVoidSelector(WorldObject const* source) : _source(source) { }
|
||||
explicit ValithriaManaVoidSelector(WorldObject const* source) : _source(source)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator()(Unit* unit) const
|
||||
{
|
||||
@@ -171,10 +173,10 @@ struct ManaVoidSelector
|
||||
WorldObject const* _source;
|
||||
};
|
||||
|
||||
class DelayedCastEvent : public BasicEvent
|
||||
class ValithriaDelayedCastEvent : public BasicEvent
|
||||
{
|
||||
public:
|
||||
DelayedCastEvent(Creature* trigger, uint32 spellId, ObjectGuid originalCaster, uint32 despawnTime) : _trigger(trigger), _originalCaster(originalCaster), _spellId(spellId), _despawnTime(despawnTime)
|
||||
ValithriaDelayedCastEvent(Creature* trigger, uint32 spellId, ObjectGuid originalCaster, uint32 despawnTime) : _trigger(trigger), _originalCaster(originalCaster), _spellId(spellId), _despawnTime(despawnTime)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -194,10 +196,10 @@ class DelayedCastEvent : public BasicEvent
|
||||
uint32 _despawnTime;
|
||||
};
|
||||
|
||||
class AuraRemoveEvent : public BasicEvent
|
||||
class ValithriaAuraRemoveEvent : public BasicEvent
|
||||
{
|
||||
public:
|
||||
AuraRemoveEvent(Creature* trigger, uint32 spellId) : _trigger(trigger), _spellId(spellId)
|
||||
ValithriaAuraRemoveEvent(Creature* trigger, uint32 spellId) : _trigger(trigger), _spellId(spellId)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -258,12 +260,13 @@ class ValithriaDespawner : public BasicEvent
|
||||
class boss_valithria_dreamwalker : public CreatureScript
|
||||
{
|
||||
public:
|
||||
boss_valithria_dreamwalker() : CreatureScript("boss_valithria_dreamwalker") { }
|
||||
boss_valithria_dreamwalker() : CreatureScript("boss_valithria_dreamwalker")
|
||||
{
|
||||
}
|
||||
|
||||
struct boss_valithria_dreamwalkerAI : public ScriptedAI
|
||||
{
|
||||
boss_valithria_dreamwalkerAI(Creature* creature) : ScriptedAI(creature),
|
||||
_instance(creature->GetInstanceScript()), _portalCount(RAID_MODE<uint32>(3, 8, 3, 8))
|
||||
boss_valithria_dreamwalkerAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()), _portalCount(RAID_MODE<uint32>(3, 8, 3, 8))
|
||||
{
|
||||
Initialize();
|
||||
_spawnHealth = me->GetHealth();
|
||||
@@ -284,8 +287,7 @@ class boss_valithria_dreamwalker : public CreatureScript
|
||||
if (data->curhealth)
|
||||
_spawnHealth = data->curhealth;
|
||||
|
||||
if (!me->isDead())
|
||||
Reset();
|
||||
ScriptedAI::InitializeAI();
|
||||
}
|
||||
|
||||
void Reset() override
|
||||
@@ -346,8 +348,10 @@ class boss_valithria_dreamwalker : public CreatureScript
|
||||
Talk(SAY_VALITHRIA_75_PERCENT);
|
||||
}
|
||||
else if (_instance->GetBossState(DATA_VALITHRIA_DREAMWALKER) == NOT_STARTED)
|
||||
{
|
||||
if (Creature* archmage = me->FindNearestCreature(NPC_RISEN_ARCHMAGE, 30.0f))
|
||||
archmage->EngageWithTarget(healer); // call JustEngagedWith on one of them, that will make it all start
|
||||
DoZoneInCombat(archmage); // on one of them, that will make it all start
|
||||
}
|
||||
}
|
||||
|
||||
void DamageTaken(Unit* /*attacker*/, uint32& damage) override
|
||||
@@ -360,7 +364,7 @@ class boss_valithria_dreamwalker : public CreatureScript
|
||||
Talk(SAY_VALITHRIA_25_PERCENT);
|
||||
}
|
||||
|
||||
if (damage > me->GetHealth())
|
||||
if (damage >= me->GetHealth())
|
||||
{
|
||||
damage = 0;
|
||||
if (!_justDied)
|
||||
@@ -397,13 +401,13 @@ class boss_valithria_dreamwalker : public CreatureScript
|
||||
{
|
||||
if (summon->GetEntry() == NPC_DREAM_PORTAL_PRE_EFFECT)
|
||||
{
|
||||
summon->m_Events.AddEvent(new DelayedCastEvent(summon, SPELL_SUMMON_DREAM_PORTAL, me->GetGUID(), 6000), summon->m_Events.CalculateTime(15000));
|
||||
summon->m_Events.AddEvent(new AuraRemoveEvent(summon, SPELL_DREAM_PORTAL_VISUAL_PRE), summon->m_Events.CalculateTime(15000));
|
||||
summon->m_Events.AddEvent(new ValithriaDelayedCastEvent(summon, SPELL_SUMMON_DREAM_PORTAL, me->GetGUID(), 6000), summon->m_Events.CalculateTime(15000));
|
||||
summon->m_Events.AddEvent(new ValithriaAuraRemoveEvent(summon, SPELL_DREAM_PORTAL_VISUAL_PRE), summon->m_Events.CalculateTime(15000));
|
||||
}
|
||||
else if (summon->GetEntry() == NPC_NIGHTMARE_PORTAL_PRE_EFFECT)
|
||||
{
|
||||
summon->m_Events.AddEvent(new DelayedCastEvent(summon, SPELL_SUMMON_NIGHTMARE_PORTAL, me->GetGUID(), 6000), summon->m_Events.CalculateTime(15000));
|
||||
summon->m_Events.AddEvent(new AuraRemoveEvent(summon, SPELL_NIGHTMARE_PORTAL_VISUAL_PRE), summon->m_Events.CalculateTime(15000));
|
||||
summon->m_Events.AddEvent(new ValithriaDelayedCastEvent(summon, SPELL_SUMMON_NIGHTMARE_PORTAL, me->GetGUID(), 6000), summon->m_Events.CalculateTime(15000));
|
||||
summon->m_Events.AddEvent(new ValithriaAuraRemoveEvent(summon, SPELL_NIGHTMARE_PORTAL_VISUAL_PRE), summon->m_Events.CalculateTime(15000));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,6 +452,9 @@ class boss_valithria_dreamwalker : public CreatureScript
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (me->HasUnitState(UNIT_STATE_CASTING))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,6 +513,9 @@ class npc_green_dragon_combat_trigger : public CreatureScript
|
||||
|
||||
void JustEnteredCombat(Unit* target) override
|
||||
{
|
||||
if (IsEngaged())
|
||||
return;
|
||||
|
||||
if (!instance->CheckRequiredBosses(DATA_VALITHRIA_DREAMWALKER, target->ToPlayer()))
|
||||
{
|
||||
EnterEvadeMode(EVADE_REASON_SEQUENCE_BREAK);
|
||||
@@ -513,6 +523,8 @@ class npc_green_dragon_combat_trigger : public CreatureScript
|
||||
return;
|
||||
}
|
||||
|
||||
EngagementStart(target);
|
||||
|
||||
me->setActive(true);
|
||||
DoZoneInCombat();
|
||||
instance->SetBossState(DATA_VALITHRIA_DREAMWALKER, IN_PROGRESS);
|
||||
@@ -564,9 +576,8 @@ class npc_green_dragon_combat_trigger : public CreatureScript
|
||||
return;
|
||||
|
||||
// check if there is any player engaged, if not - evade
|
||||
for (auto const& pair : me->GetCombatManager().GetPvECombatRefs())
|
||||
if (pair.second->GetOther(me)->GetTypeId() == TYPEID_PLAYER)
|
||||
return;
|
||||
if (me->GetCombatManager().HasPvECombatWithPlayers())
|
||||
return;
|
||||
|
||||
EnterEvadeMode();
|
||||
}
|
||||
@@ -588,8 +599,7 @@ class npc_the_lich_king_controller : public CreatureScript
|
||||
|
||||
struct npc_the_lich_king_controllerAI : public ScriptedAI
|
||||
{
|
||||
npc_the_lich_king_controllerAI(Creature* creature) : ScriptedAI(creature),
|
||||
_instance(creature->GetInstanceScript())
|
||||
npc_the_lich_king_controllerAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -627,7 +637,7 @@ class npc_the_lich_king_controller : public CreatureScript
|
||||
{
|
||||
// must not be in dream phase
|
||||
PhasingHandler::RemovePhase(summon, 173, true);
|
||||
summon->AI()->DoZoneInCombat();
|
||||
DoZoneInCombat(summon);
|
||||
if (summon->GetEntry() != NPC_SUPPRESSER)
|
||||
if (Unit* target = me->GetCombatManager().GetAnyTarget())
|
||||
summon->AI()->AttackStart(target);
|
||||
@@ -665,6 +675,9 @@ class npc_the_lich_king_controller : public CreatureScript
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (me->HasUnitState(UNIT_STATE_CASTING))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -686,15 +699,13 @@ class npc_risen_archmage : public CreatureScript
|
||||
|
||||
struct npc_risen_archmageAI : public ScriptedAI
|
||||
{
|
||||
npc_risen_archmageAI(Creature* creature) : ScriptedAI(creature),
|
||||
_instance(creature->GetInstanceScript())
|
||||
npc_risen_archmageAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript())
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
_canCallJustEngagedWith = true;
|
||||
_isInitialArchmage = false;
|
||||
}
|
||||
|
||||
@@ -712,33 +723,29 @@ class npc_risen_archmage : public CreatureScript
|
||||
Initialize();
|
||||
}
|
||||
|
||||
void JustEngagedWith(Unit* target) override
|
||||
void JustEnteredCombat(Unit* who) override
|
||||
{
|
||||
if (IsEngaged())
|
||||
return;
|
||||
|
||||
me->InterruptNonMeleeSpells(false);
|
||||
if (_isInitialArchmage && _canCallJustEngagedWith)
|
||||
|
||||
EngagementStart(who);
|
||||
|
||||
if (_isInitialArchmage)
|
||||
{
|
||||
if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_LICH_KING)))
|
||||
{
|
||||
lichKing->EngageWithTarget(target);
|
||||
lichKing->AI()->DoZoneInCombat();
|
||||
}
|
||||
DoZoneInCombat(lichKing);
|
||||
|
||||
if (Creature* trigger = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_TRIGGER)))
|
||||
{
|
||||
trigger->EngageWithTarget(target);
|
||||
trigger->AI()->DoZoneInCombat();
|
||||
}
|
||||
DoZoneInCombat(trigger);
|
||||
}
|
||||
}
|
||||
|
||||
void DoAction(int32 action) override
|
||||
{
|
||||
if (action == ACTION_ENTER_COMBAT)
|
||||
{
|
||||
_canCallJustEngagedWith = false;
|
||||
DoZoneInCombat();
|
||||
_canCallJustEngagedWith = true;
|
||||
}
|
||||
else if (action == ACTION_SETUP_ARCHMAGES)
|
||||
_isInitialArchmage = true;
|
||||
}
|
||||
@@ -748,7 +755,7 @@ class npc_risen_archmage : public CreatureScript
|
||||
if (summon->GetEntry() == NPC_COLUMN_OF_FROST)
|
||||
{
|
||||
summon->CastSpell(summon, SPELL_COLUMN_OF_FROST_AURA, true);
|
||||
summon->m_Events.AddEvent(new DelayedCastEvent(summon, SPELL_COLUMN_OF_FROST_DAMAGE, ObjectGuid::Empty, 8000), summon->m_Events.CalculateTime(2000));
|
||||
summon->m_Events.AddEvent(new ValithriaDelayedCastEvent(summon, SPELL_COLUMN_OF_FROST_DAMAGE, ObjectGuid::Empty, 8000), summon->m_Events.CalculateTime(2000));
|
||||
}
|
||||
else if (summon->GetEntry() == NPC_MANA_VOID)
|
||||
{
|
||||
@@ -779,7 +786,7 @@ class npc_risen_archmage : public CreatureScript
|
||||
_events.ScheduleEvent(EVENT_FROSTBOLT_VOLLEY, 8s, 15s);
|
||||
break;
|
||||
case EVENT_MANA_VOID:
|
||||
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, ManaVoidSelector(me)))
|
||||
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, ValithriaManaVoidSelector(me)))
|
||||
DoCast(target, SPELL_MANA_VOID);
|
||||
_events.ScheduleEvent(EVENT_MANA_VOID, 20s, 25s);
|
||||
break;
|
||||
@@ -791,6 +798,9 @@ class npc_risen_archmage : public CreatureScript
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (me->HasUnitState(UNIT_STATE_CASTING))
|
||||
return;
|
||||
}
|
||||
|
||||
DoMeleeAttackIfReady();
|
||||
@@ -799,7 +809,6 @@ class npc_risen_archmage : public CreatureScript
|
||||
private:
|
||||
EventMap _events;
|
||||
InstanceScript* _instance;
|
||||
bool _canCallJustEngagedWith;
|
||||
bool _isInitialArchmage;
|
||||
};
|
||||
|
||||
@@ -853,6 +862,9 @@ class npc_blazing_skeleton : public CreatureScript
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (me->HasUnitState(UNIT_STATE_CASTING))
|
||||
return;
|
||||
}
|
||||
|
||||
DoMeleeAttackIfReady();
|
||||
@@ -1037,8 +1049,7 @@ class npc_dream_portal : public CreatureScript
|
||||
|
||||
struct npc_dream_portalAI : public CreatureAI
|
||||
{
|
||||
npc_dream_portalAI(Creature* creature) : CreatureAI(creature),
|
||||
_used(false)
|
||||
npc_dream_portalAI(Creature* creature) : CreatureAI(creature), _used(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1078,8 +1089,7 @@ class npc_dream_cloud : public CreatureScript
|
||||
|
||||
struct npc_dream_cloudAI : public ScriptedAI
|
||||
{
|
||||
npc_dream_cloudAI(Creature* creature) : ScriptedAI(creature),
|
||||
_instance(creature->GetInstanceScript())
|
||||
npc_dream_cloudAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1087,7 +1097,7 @@ class npc_dream_cloud : public CreatureScript
|
||||
{
|
||||
_events.Reset();
|
||||
_events.ScheduleEvent(EVENT_CHECK_PLAYER, 1s);
|
||||
me->SetCorpseDelay(0); // remove corpse immediately
|
||||
me->SetCorpseDelay(0); // remove corpse immediately
|
||||
me->LoadCreaturesAddon();
|
||||
}
|
||||
|
||||
@@ -1175,13 +1185,6 @@ class spell_dreamwalker_decay_periodic_timer : public SpellScriptLoader
|
||||
{
|
||||
PrepareAuraScript(spell_dreamwalker_decay_periodic_timer_AuraScript);
|
||||
|
||||
public:
|
||||
spell_dreamwalker_decay_periodic_timer_AuraScript()
|
||||
{
|
||||
_decayRate = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
bool Load() override
|
||||
{
|
||||
_decayRate = GetId() != SPELL_TIMER_BLAZING_SKELETON ? 1000 : 5000;
|
||||
@@ -1202,7 +1205,7 @@ class spell_dreamwalker_decay_periodic_timer : public SpellScriptLoader
|
||||
OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_dreamwalker_decay_periodic_timer_AuraScript::DecayPeriodicTimer, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
|
||||
}
|
||||
|
||||
int32 _decayRate;
|
||||
int32 _decayRate = 0;
|
||||
};
|
||||
|
||||
AuraScript* GetAuraScript() const override
|
||||
@@ -1468,9 +1471,6 @@ class spell_dreamwalker_twisted_nightmares : public SpellScriptLoader
|
||||
void HandleScript(SpellEffIndex effIndex)
|
||||
{
|
||||
PreventHitDefaultEffect(effIndex);
|
||||
// impossible with TARGET_UNIT_CASTER
|
||||
//if (!GetHitUnit())
|
||||
// return;
|
||||
|
||||
if (GetHitUnit()->GetInstanceScript())
|
||||
GetHitUnit()->CastSpell(nullptr, GetEffectInfo().TriggerSpell, CastSpellExtraArgs(TRIGGERED_FULL_MASK)
|
||||
|
||||
Reference in New Issue
Block a user