Scripts/Malygos: - Applied TC code style.

- Every Hover Disk will correctly change the faction once the creature passenger dies.
                 - Player's mount will be despawned when the passenger leaves it.
This commit is contained in:
Manuel Carrasco
2011-08-12 16:29:43 -03:00
parent f797f9f74d
commit d9d5bce568
@@ -24,7 +24,6 @@ Script Data End */
// Find sniffed spawn position for chest // Find sniffed spawn position for chest
// Implement a better way to disappear the gameobjects // Implement a better way to disappear the gameobjects
// Implement achievements // Implement achievements
// Implement scaling for player's drakes (should be done with aura 66668, it is casted - but it is not working as it should)
// Remove hack that re-adds targets to the aggro list after they enter to a vehicle when it works as expected // Remove hack that re-adds targets to the aggro list after they enter to a vehicle when it works as expected
// Improve whatever can be improved :) // Improve whatever can be improved :)
@@ -221,53 +220,52 @@ public:
boss_malygosAI(Creature* creature) : BossAI(creature, DATA_MALYGOS_EVENT) boss_malygosAI(Creature* creature) : BossAI(creature, DATA_MALYGOS_EVENT)
{ {
// If we enter in combat when MovePoint generator is active, it overrwrites our homeposition // If we enter in combat when MovePoint generator is active, it overrwrites our homeposition
homePosition = creature->GetHomePosition(); _homePosition = creature->GetHomePosition();
} }
void Reset() void Reset()
{ {
_Reset(); _Reset();
bersekerTimer = 0; _bersekerTimer = 0;
currentPos = 0; _currentPos = 0;
SetPhase(PHASE_ONE, true); SetPhase(PHASE_ONE, true);
delayedMovementTimer = 8000; _delayedMovementTimer = 8000;
delayedMovement = false; _delayedMovement = false;
summonDeaths = 0; _summonDeaths = 0;
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
cannotMove = true; _cannotMove = true;
} }
uint32 GetData(uint32 data) uint32 GetData(uint32 data)
{ {
if (data == DATA_SUMMON_DEATHS) if (data == DATA_SUMMON_DEATHS)
return summonDeaths; return _summonDeaths;
else if (data == DATA_PHASE) else if (data == DATA_PHASE)
return phase; return _phase;
return 0; return 0;
} }
void SetData(uint32 data, uint32 value) void SetData(uint32 data, uint32 value)
{ {
if (data == DATA_SUMMON_DEATHS && phase == PHASE_TWO) if (data == DATA_SUMMON_DEATHS && _phase == PHASE_TWO)
{ {
summonDeaths = value; _summonDeaths = value;
if (summonDeaths >= MAX_SUMMONS_PHASE_TWO) if (_summonDeaths >= MAX_SUMMONS_PHASE_TWO)
StartPhaseThree(); StartPhaseThree();
} }
} }
void EnterEvadeMode() void EnterEvadeMode()
{ {
me->SetHomePosition(homePosition); me->SetHomePosition(_homePosition);
me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
@@ -277,15 +275,15 @@ public:
instance->SetBossState(DATA_MALYGOS_EVENT, FAIL); instance->SetBossState(DATA_MALYGOS_EVENT, FAIL);
} }
void SetPhase(uint8 _phase, bool setEvents = false) void SetPhase(uint8 phase, bool setEvents = false)
{ {
events.Reset(); events.Reset();
events.SetPhase(_phase); events.SetPhase(phase);
phase = _phase; _phase = phase;
if (setEvents) if (setEvents)
SetPhaseEvents(_phase); SetPhaseEvents();
} }
void StartPhaseThree() void StartPhaseThree()
@@ -320,7 +318,7 @@ public:
me->GetMotionMaster()->MovePoint(MOVE_CENTER_PLATFORM, MalygosPositions[0].GetPositionX(), MalygosPositions[0].GetPositionY(), MalygosPositions[0].GetPositionZ()); me->GetMotionMaster()->MovePoint(MOVE_CENTER_PLATFORM, MalygosPositions[0].GetPositionX(), MalygosPositions[0].GetPositionY(), MalygosPositions[0].GetPositionZ());
} }
void SetPhaseEvents(uint8 _phase) void SetPhaseEvents()
{ {
switch (_phase) switch (_phase)
{ {
@@ -365,7 +363,7 @@ public:
if (who->GetTypeId() != TYPEID_PLAYER) if (who->GetTypeId() != TYPEID_PLAYER)
return; return;
switch (phase) switch (_phase)
{ {
case PHASE_ONE: case PHASE_ONE:
Talk(SAY_KILLED_PLAYER_P_ONE); Talk(SAY_KILLED_PLAYER_P_ONE);
@@ -400,7 +398,6 @@ public:
// not sure about the distance | I think it is better check this here than in the UpdateAI function... // not sure about the distance | I think it is better check this here than in the UpdateAI function...
if (who->GetDistance(me) <= 2.5f) if (who->GetDistance(me) <= 2.5f)
who->CastSpell(me, SPELL_POWER_SPARK_MALYGOS, true); who->CastSpell(me, SPELL_POWER_SPARK_MALYGOS, true);
} }
} }
@@ -434,15 +431,15 @@ public:
ExecuteVortex(); ExecuteVortex();
break; break;
case MOVE_DEEP_BREATH_ROTATION: case MOVE_DEEP_BREATH_ROTATION:
currentPos = currentPos == MALYGOS_MAX_WAYPOINTS - 1 ? 0 : currentPos+1; _currentPos = _currentPos == MALYGOS_MAX_WAYPOINTS - 1 ? 0 : _currentPos+1;
me->GetMotionMaster()->MovementExpired(); me->GetMotionMaster()->MovementExpired();
me->GetMotionMaster()->MovePoint(MOVE_DEEP_BREATH_ROTATION, MalygosPhaseTwoWaypoints[currentPos]); me->GetMotionMaster()->MovePoint(MOVE_DEEP_BREATH_ROTATION, MalygosPhaseTwoWaypoints[_currentPos]);
break; break;
case MOVE_INIT_PHASE_ONE: case MOVE_INIT_PHASE_ONE:
me->SetInCombatWithZone(); me->SetInCombatWithZone();
break; break;
case MOVE_CENTER_PLATFORM: case MOVE_CENTER_PLATFORM:
cannotMove = false; _cannotMove = false;
// malygos will move into center of platform and then he does not chase dragons, he just turns to his current target. // malygos will move into center of platform and then he does not chase dragons, he just turns to his current target.
me->GetMotionMaster()->MoveIdle(); me->GetMotionMaster()->MoveIdle();
break; break;
@@ -481,9 +478,9 @@ public:
events.Update(diff); events.Update(diff);
if (phase == PHASE_THREE) if (_phase == PHASE_THREE)
{ {
if (!cannotMove) if (!_cannotMove)
{ {
// it can change if the player falls from the vehicle. // it can change if the player falls from the vehicle.
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE) if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE)
@@ -502,18 +499,18 @@ public:
} }
// we need a better way for pathing // we need a better way for pathing
if (delayedMovement) if (_delayedMovement)
{ {
if (delayedMovementTimer <= diff) if (_delayedMovementTimer <= diff)
{ {
me->GetMotionMaster()->MovePoint(MOVE_DEEP_BREATH_ROTATION, MalygosPhaseTwoWaypoints[currentPos]); me->GetMotionMaster()->MovePoint(MOVE_DEEP_BREATH_ROTATION, MalygosPhaseTwoWaypoints[_currentPos]);
delayedMovementTimer = 8000; _delayedMovementTimer = 8000;
delayedMovement = false; _delayedMovement = false;
} delayedMovementTimer -= diff; } _delayedMovementTimer -= diff;
} }
// at 50 % health malygos switch to phase 2 // at 50 % health malygos switch to phase 2
if (me->GetHealthPct() <= 50.0f && phase == PHASE_ONE) if (me->GetHealthPct() <= 50.0f && _phase == PHASE_ONE)
StartPhaseTwo(); StartPhaseTwo();
// the boss is handling vortex // the boss is handling vortex
@@ -561,7 +558,7 @@ public:
break; break;
case EVENT_SURGE_POWER: case EVENT_SURGE_POWER:
me->GetMotionMaster()->MoveIdle(); me->GetMotionMaster()->MoveIdle();
delayedMovement = true; _delayedMovement = true;
DoCast(SPELL_SURGE_POWER); DoCast(SPELL_SURGE_POWER);
events.ScheduleEvent(EVENT_SURGE_POWER, urand(60, 70)*IN_MILLISECONDS, 0, PHASE_TWO); events.ScheduleEvent(EVENT_SURGE_POWER, urand(60, 70)*IN_MILLISECONDS, 0, PHASE_TWO);
break; break;
@@ -611,17 +608,16 @@ public:
} }
private: private:
uint8 phase; uint8 _phase;
uint32 bersekerTimer; uint32 _bersekerTimer;
uint8 currentPos; // used for phase 2 rotation... uint8 _currentPos; // used for phase 2 rotation...
bool delayedMovement; // used in phase2. bool _delayedMovement; // used in phase 2.
uint32 delayedMovementTimer; // used in phase 2 uint32 _delayedMovementTimer; // used in phase 2
uint8 summonDeaths; uint8 _summonDeaths;
Position homePosition; // it can get bugged because core thinks we are pathing Position _homePosition; // it can get bugged because core thinks we are pathing
bool mustTalk; bool _mustTalk;
bool cannotMove; bool _cannotMove;
}; };
}; };
class spell_malygos_vortex_dummy : public SpellScriptLoader class spell_malygos_vortex_dummy : public SpellScriptLoader
@@ -733,12 +729,12 @@ public:
{ {
npc_portal_eoeAI(Creature* creature) : ScriptedAI(creature) npc_portal_eoeAI(Creature* creature) : ScriptedAI(creature)
{ {
instance = creature->GetInstanceScript(); _instance = creature->GetInstanceScript();
} }
void Reset() void Reset()
{ {
summonTimer = urand(5, 7)*IN_MILLISECONDS; _summonTimer = urand(5, 7)*IN_MILLISECONDS;
} }
void UpdateAI(uint32 const diff) void UpdateAI(uint32 const diff)
@@ -747,9 +743,9 @@ public:
!me->HasAura(SPELL_PORTAL_OPENED)) !me->HasAura(SPELL_PORTAL_OPENED))
DoCast(me, SPELL_PORTAL_VISUAL_CLOSED, true); DoCast(me, SPELL_PORTAL_VISUAL_CLOSED, true);
if (instance) if (_instance)
{ {
if (Creature* malygos = Unit::GetCreature(*me, instance->GetData64(DATA_MALYGOS))) if (Creature* malygos = Unit::GetCreature(*me, _instance->GetData64(DATA_MALYGOS)))
{ {
if (malygos->AI()->GetData(DATA_PHASE) != PHASE_ONE) if (malygos->AI()->GetData(DATA_PHASE) != PHASE_ONE)
{ {
@@ -762,11 +758,12 @@ public:
if (!me->HasAura(SPELL_PORTAL_OPENED)) if (!me->HasAura(SPELL_PORTAL_OPENED))
return; return;
if (summonTimer <= diff) if (_summonTimer <= diff)
{ {
DoCast(SPELL_SUMMON_POWER_PARK); DoCast(SPELL_SUMMON_POWER_PARK);
summonTimer = urand(5, 7)*IN_MILLISECONDS; _summonTimer = urand(5, 7)*IN_MILLISECONDS;
} else summonTimer -= diff; } else
_summonTimer -= diff;
} }
void JustSummoned(Creature* summon) void JustSummoned(Creature* summon)
@@ -775,8 +772,8 @@ public:
} }
private: private:
uint32 summonTimer; uint32 _summonTimer;
InstanceScript* instance; InstanceScript* _instance;
}; };
}; };
@@ -795,7 +792,7 @@ public:
{ {
npc_power_sparkAI(Creature* creature) : ScriptedAI(creature) npc_power_sparkAI(Creature* creature) : ScriptedAI(creature)
{ {
instance = creature->GetInstanceScript(); _instance = creature->GetInstanceScript();
MoveToMalygos(); MoveToMalygos();
} }
@@ -809,19 +806,19 @@ public:
{ {
me->GetMotionMaster()->MoveIdle(); me->GetMotionMaster()->MoveIdle();
if (instance) if (_instance)
{ {
if (Creature* malygos = Unit::GetCreature(*me, instance->GetData64(DATA_MALYGOS))) if (Creature* malygos = Unit::GetCreature(*me, _instance->GetData64(DATA_MALYGOS)))
me->GetMotionMaster()->MoveFollow(malygos, 0.0f, 0.0f); me->GetMotionMaster()->MoveFollow(malygos, 0.0f, 0.0f);
} }
} }
void UpdateAI(uint32 const /*diff*/) void UpdateAI(uint32 const /*diff*/)
{ {
if (!instance) if (!_instance)
return; return;
if (Creature* malygos = Unit::GetCreature(*me, instance->GetData64(DATA_MALYGOS))) if (Creature* malygos = Unit::GetCreature(*me, _instance->GetData64(DATA_MALYGOS)))
{ {
if (malygos->AI()->GetData(DATA_PHASE) != PHASE_ONE) if (malygos->AI()->GetData(DATA_PHASE) != PHASE_ONE)
{ {
@@ -851,7 +848,7 @@ public:
} }
private: private:
InstanceScript* instance; InstanceScript* _instance;
}; };
}; };
@@ -874,7 +871,7 @@ public:
else else
me->SetInCombatWithZone(); me->SetInCombatWithZone();
instance = creature->GetInstanceScript(); _instance = creature->GetInstanceScript();
} }
void PassengerBoarded(Unit* unit, int8 /*seat*/, bool apply) void PassengerBoarded(Unit* unit, int8 /*seat*/, bool apply)
@@ -894,9 +891,9 @@ public:
if (unit->GetTypeId() == TYPEID_UNIT) if (unit->GetTypeId() == TYPEID_UNIT)
{ {
// This will only be called if the passenger dies // This will only be called if the passenger dies
if (instance) if (_instance)
{ {
if (Creature* malygos = Unit::GetCreature(*me, instance->GetData64(DATA_MALYGOS))) if (Creature* malygos = Unit::GetCreature(*me, _instance->GetData64(DATA_MALYGOS)))
malygos->AI()->SetData(DATA_SUMMON_DEATHS, malygos->AI()->GetData(DATA_SUMMON_DEATHS)+1); malygos->AI()->SetData(DATA_SUMMON_DEATHS, malygos->AI()->GetData(DATA_SUMMON_DEATHS)+1);
} }
@@ -905,7 +902,7 @@ public:
me->GetMotionMaster()->MoveIdle(); me->GetMotionMaster()->MoveIdle();
if (me->GetEntry() == NPC_HOVER_DISK_MELEE) if (me->GetEntry() == NPC_HOVER_DISK_MELEE || me->GetEntry() == NPC_HOVER_DISK_CASTER)
{ {
// Hack: Fall ground function can fail (remember the platform is a gameobject), we will teleport the disk to the ground // Hack: Fall ground function can fail (remember the platform is a gameobject), we will teleport the disk to the ground
if (me->GetPositionZ() > GROUND_Z) if (me->GetPositionZ() > GROUND_Z)
@@ -960,7 +957,7 @@ public:
} }
private: private:
InstanceScript* instance; InstanceScript* _instance;
}; };
}; };
@@ -1013,47 +1010,54 @@ public:
{ {
npc_wyrmrest_skytalonAI(Creature* creature) : NullCreatureAI(creature) npc_wyrmrest_skytalonAI(Creature* creature) : NullCreatureAI(creature)
{ {
instance = creature->GetInstanceScript(); _instance = creature->GetInstanceScript();
timer = 1000; _timer = 1000;
entered = false; _entered = false;
}
void PassengerBoarded(Unit* /*unit*/, int8 /*seat*/, bool apply)
{
if (!apply)
me->DespawnOrUnsummon();
} }
// we can't call this in reset function, it fails. // we can't call this in reset function, it fails.
void MakePlayerEnter() void MakePlayerEnter()
{ {
if (!instance) if (!_instance)
return; return;
if (Unit* summoner = me->ToTempSummon()->GetSummoner()) if (Unit* summoner = me->ToTempSummon()->GetSummoner())
{ {
if (Creature* malygos = Unit::GetCreature(*me, instance->GetData64(DATA_MALYGOS))) if (Creature* malygos = Unit::GetCreature(*me, _instance->GetData64(DATA_MALYGOS)))
{ {
summoner->CastSpell(me, SPELL_RIDE_RED_DRAGON, true); summoner->CastSpell(me, SPELL_RIDE_RED_DRAGON, true);
float victim_threat = malygos->getThreatManager().getThreat(summoner); float victimThreat = malygos->getThreatManager().getThreat(summoner);
malygos->getThreatManager().resetAllAggro(); malygos->getThreatManager().resetAllAggro();
malygos->AI()->AttackStart(me); malygos->AI()->AttackStart(me);
malygos->AddThreat(me, victim_threat); malygos->AddThreat(me, victimThreat);
} }
} }
} }
void UpdateAI(const uint32 diff) void UpdateAI(const uint32 diff)
{ {
if (!entered) if (!_entered)
{ {
if (timer <= diff) if (_timer <= diff)
{ {
MakePlayerEnter(); MakePlayerEnter();
entered = true; _entered = true;
} else timer -= diff; } else
_timer -= diff;
} }
} }
private: private:
InstanceScript* instance; InstanceScript* _instance;
uint32 timer; uint32 _timer;
bool entered; bool _entered;
}; };
}; };
@@ -1068,7 +1072,7 @@ enum AlexstraszaYells
class npc_alexstrasza_eoe : public CreatureScript class npc_alexstrasza_eoe : public CreatureScript
{ {
public: public:
npc_alexstrasza_eoe() : CreatureScript("npc_alexstrasza_eoe") { } npc_alexstrasza_eoe() : CreatureScript("npc_alexstrasza_eoe") {}
CreatureAI* GetAI(Creature* creature) const CreatureAI* GetAI(Creature* creature) const
{ {
@@ -1081,28 +1085,27 @@ public:
void Reset() void Reset()
{ {
events.Reset(); _events.Reset();
_events.ScheduleEvent(EVENT_YELL_1, 0);
events.ScheduleEvent(EVENT_YELL_1, 0);
} }
void UpdateAI(uint32 const /*diff*/) void UpdateAI(uint32 const /*diff*/)
{ {
while (uint32 eventId = events.ExecuteEvent()) while (uint32 eventId = _events.ExecuteEvent())
{ {
switch (eventId) switch (eventId)
{ {
case EVENT_YELL_1: case EVENT_YELL_1:
Talk(SAY_ONE); Talk(SAY_ONE);
events.ScheduleEvent(EVENT_YELL_2, 4*IN_MILLISECONDS); _events.ScheduleEvent(EVENT_YELL_2, 4*IN_MILLISECONDS);
break; break;
case EVENT_YELL_2: case EVENT_YELL_2:
Talk(SAY_TWO); Talk(SAY_TWO);
events.ScheduleEvent(EVENT_YELL_3, 4*IN_MILLISECONDS); _events.ScheduleEvent(EVENT_YELL_3, 4*IN_MILLISECONDS);
break; break;
case EVENT_YELL_3: case EVENT_YELL_3:
Talk(SAY_THREE); Talk(SAY_THREE);
events.ScheduleEvent(EVENT_YELL_4, 7*IN_MILLISECONDS); _events.ScheduleEvent(EVENT_YELL_4, 7*IN_MILLISECONDS);
break; break;
case EVENT_YELL_4: case EVENT_YELL_4:
Talk(SAY_FOUR); Talk(SAY_FOUR);
@@ -1111,14 +1114,14 @@ public:
} }
} }
private: private:
EventMap events; EventMap _events;
}; };
}; };
class achievement_denyin_the_scion : public AchievementCriteriaScript class achievement_denyin_the_scion : public AchievementCriteriaScript
{ {
public: public:
achievement_denyin_the_scion() : AchievementCriteriaScript("achievement_denyin_the_scion") { } achievement_denyin_the_scion() : AchievementCriteriaScript("achievement_denyin_the_scion") {}
bool OnCheck(Player* source, Unit* /*target*/) bool OnCheck(Player* source, Unit* /*target*/)
{ {