chore(Scripts/OnyxiasLair): Fix broken code style (#9367)

This commit is contained in:
Skjalf
2021-11-26 12:47:22 -03:00
committed by GitHub
parent 625b392ffe
commit 8fd713ac52
2 changed files with 124 additions and 82 deletions
@@ -140,7 +140,7 @@ public:
{ {
events.Reset(); events.Reset();
Phase = ph; Phase = ph;
switch( ph ) switch (ph)
{ {
case 0: case 0:
break; break;
@@ -173,29 +173,40 @@ public:
whelpSpamTimer = 0; whelpSpamTimer = 0;
bManyWhelpsAvailable = false; bManyWhelpsAvailable = false;
if( m_pInstance ) if (m_pInstance)
{ {
m_pInstance->SetData(DATA_ONYXIA, NOT_STARTED); m_pInstance->SetData(DATA_ONYXIA, NOT_STARTED);
m_pInstance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT); m_pInstance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
} }
} }
void JustDied(Unit* /*killer*/) override
{
m_pInstance->SetData(DATA_ONYXIA, DONE);
}
void MoveInLineOfSight(Unit* who) override void MoveInLineOfSight(Unit* who) override
{ {
if( me->GetVictim() || me->GetDistance(who) > 30.0f ) if (me->GetVictim() || me->GetDistance(who) > 30.0f)
{
return; return;
}
if( who->GetTypeId() == TYPEID_PLAYER ) if (who->GetTypeId() == TYPEID_PLAYER)
{
AttackStart(who); AttackStart(who);
} }
}
void DoAction(int32 param) override void DoAction(int32 param) override
{ {
switch( param ) switch (param)
{ {
case -1: case -1:
if( bManyWhelpsAvailable && m_pInstance ) if (bManyWhelpsAvailable && m_pInstance)
{
m_pInstance->SetData(DATA_WHELP_SUMMONED, 1); m_pInstance->SetData(DATA_WHELP_SUMMONED, 1);
}
break; break;
} }
} }
@@ -211,7 +222,7 @@ public:
DoZoneInCombat(); DoZoneInCombat();
SetPhase(1); SetPhase(1);
if( m_pInstance ) if (m_pInstance)
{ {
m_pInstance->SetData(DATA_ONYXIA, IN_PROGRESS); m_pInstance->SetData(DATA_ONYXIA, IN_PROGRESS);
m_pInstance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT); // just in case at reset some players already left the instance m_pInstance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT); // just in case at reset some players already left the instance
@@ -220,22 +231,18 @@ public:
BindPlayers(); BindPlayers();
} }
void JustDied(Unit* /*killer*/) override
{
if( m_pInstance )
m_pInstance->SetData(DATA_ONYXIA, DONE);
}
void DamageTaken(Unit*, uint32& /*damage*/, DamageEffectType, SpellSchoolMask) override void DamageTaken(Unit*, uint32& /*damage*/, DamageEffectType, SpellSchoolMask) override
{ {
switch( Phase ) switch (Phase)
{ {
case 1: case 1:
if( me->GetHealth() * 100 / me->GetMaxHealth() <= 65 ) if (me->GetHealth() * 100 / me->GetMaxHealth() <= 65)
{
SetPhase(2); SetPhase(2);
}
break; break;
case 2: case 2:
if( me->GetHealth() * 100 / me->GetMaxHealth() <= 40 ) if (me->GetHealth() * 100 / me->GetMaxHealth() <= 40)
{ {
me->InterruptNonMeleeSpells(false); me->InterruptNonMeleeSpells(false);
SetPhase(3); SetPhase(3);
@@ -246,11 +253,12 @@ public:
void JustSummoned(Creature* pSummoned) override void JustSummoned(Creature* pSummoned) override
{ {
if( !pSummoned ) if (pSummoned->GetEntry() != NPC_ONYXIAN_WHELP && pSummoned->GetEntry() != NPC_ONYXIAN_LAIR_GUARD)
{
return; return;
if( pSummoned->GetEntry() != NPC_ONYXIAN_WHELP && pSummoned->GetEntry() != NPC_ONYXIAN_LAIR_GUARD ) }
return;
if( Unit* target = pSummoned->SelectNearestTarget(300.0f) ) if (Unit* target = pSummoned->SelectNearestTarget(300.0f))
{ {
pSummoned->AI()->AttackStart(target); pSummoned->AI()->AttackStart(target);
DoZoneInCombat(pSummoned); DoZoneInCombat(pSummoned);
@@ -259,12 +267,14 @@ public:
void MovementInform(uint32 type, uint32 id) override void MovementInform(uint32 type, uint32 id) override
{ {
if( type != POINT_MOTION_TYPE && type != EFFECT_MOTION_TYPE ) if (type != POINT_MOTION_TYPE && type != EFFECT_MOTION_TYPE)
return;
if( id < 9 )
{ {
if( id > 0 && Phase == 2 ) return;
}
if (id < 9)
{
if (id > 0 && Phase == 2)
{ {
me->SetFacingTo(OnyxiaMoveData[id].o); me->SetFacingTo(OnyxiaMoveData[id].o);
me->SetSpeed(MOVE_RUN, 1.6f, false); me->SetSpeed(MOVE_RUN, 1.6f, false);
@@ -272,7 +282,9 @@ public:
events.ScheduleEvent(EVENT_SPELL_FIREBALL_FIRST, 1000); events.ScheduleEvent(EVENT_SPELL_FIREBALL_FIRST, 1000);
} }
} }
else switch( id ) else
{
switch (id)
{ {
case 10: case 10:
me->SetFacingTo(OnyxiaMoveData[0].o); me->SetFacingTo(OnyxiaMoveData[0].o);
@@ -294,15 +306,16 @@ public:
break; break;
} }
} }
}
void HandleWhelpSpam(const uint32 diff) void HandleWhelpSpam(const uint32 diff)
{ {
if( whelpSpam ) if (whelpSpam)
{ {
if( whelpCount < 40 ) if (whelpCount < 40)
{ {
whelpSpamTimer -= diff; whelpSpamTimer -= diff;
if( whelpSpamTimer <= 0 ) if (whelpSpamTimer <= 0)
{ {
float angle = rand_norm() * 2 * M_PI; float angle = rand_norm() * 2 * M_PI;
float dist = rand_norm() * 4.0f; float dist = rand_norm() * 4.0f;
@@ -323,18 +336,22 @@ public:
void UpdateAI(uint32 diff) override void UpdateAI(uint32 diff) override
{ {
if( !UpdateVictim() ) if (!UpdateVictim())
{
return; return;
}
events.Update(diff); events.Update(diff);
HandleWhelpSpam(diff); HandleWhelpSpam(diff);
if( me->HasUnitState(UNIT_STATE_CASTING) ) if (me->HasUnitState(UNIT_STATE_CASTING))
{
return; return;
}
DoMeleeAttackIfReady(); DoMeleeAttackIfReady();
switch( events.ExecuteEvent() ) switch (events.ExecuteEvent())
{ {
case 0: case 0:
break; break;
@@ -422,7 +439,7 @@ public:
break; break;
case EVENT_SPELL_FIREBALL_FIRST: case EVENT_SPELL_FIREBALL_FIRST:
{ {
if( Unit* v = SelectTarget(SELECT_TARGET_RANDOM, 0, 200.0f, true) ) if (Unit* v = SelectTarget(SELECT_TARGET_RANDOM, 0, 200.0f, true))
{ {
me->SetFacingToObject(v); me->SetFacingToObject(v);
me->CastSpell(v, SPELL_FIREBALL, false); me->CastSpell(v, SPELL_FIREBALL, false);
@@ -433,34 +450,44 @@ public:
break; break;
case EVENT_SPELL_FIREBALL_SECOND: case EVENT_SPELL_FIREBALL_SECOND:
{ {
if( Unit* v = SelectTarget(SELECT_TARGET_RANDOM, 0, 200.0f, true) ) if (Unit* v = SelectTarget(SELECT_TARGET_RANDOM, 0, 200.0f, true))
{ {
me->SetFacingToObject(v); me->SetFacingToObject(v);
me->CastSpell(v, SPELL_FIREBALL, false); me->CastSpell(v, SPELL_FIREBALL, false);
} }
uint8 rand = urand(0, 99); uint8 rand = urand(0, 99);
if( rand < 33 ) if (rand < 33)
{
events.ScheduleEvent(EVENT_PHASE_2_STEP_CW, 4000); events.ScheduleEvent(EVENT_PHASE_2_STEP_CW, 4000);
else if( rand < 66 ) }
else if (rand < 66)
{
events.ScheduleEvent(EVENT_PHASE_2_STEP_ACW, 4000); events.ScheduleEvent(EVENT_PHASE_2_STEP_ACW, 4000);
}
else else
{
events.ScheduleEvent(EVENT_PHASE_2_STEP_ACROSS, 4000); events.ScheduleEvent(EVENT_PHASE_2_STEP_ACROSS, 4000);
} }
}
break; break;
case EVENT_PHASE_2_STEP_CW: case EVENT_PHASE_2_STEP_CW:
{ {
uint8 newWP = CurrentWP + 1; uint8 newWP = CurrentWP + 1;
if( newWP > 8 ) if (newWP > 8)
{
newWP = 1; newWP = 1;
}
me->GetMotionMaster()->MovePoint(newWP, OnyxiaMoveData[newWP].x, OnyxiaMoveData[newWP].y, OnyxiaMoveData[newWP].z); me->GetMotionMaster()->MovePoint(newWP, OnyxiaMoveData[newWP].x, OnyxiaMoveData[newWP].y, OnyxiaMoveData[newWP].z);
} }
break; break;
case EVENT_PHASE_2_STEP_ACW: case EVENT_PHASE_2_STEP_ACW:
{ {
uint8 newWP = CurrentWP - 1; uint8 newWP = CurrentWP - 1;
if( newWP < 1 ) if (newWP < 1)
{
newWP = 8; newWP = 8;
}
me->GetMotionMaster()->MovePoint(newWP, OnyxiaMoveData[newWP].x, OnyxiaMoveData[newWP].y, OnyxiaMoveData[newWP].z); me->GetMotionMaster()->MovePoint(newWP, OnyxiaMoveData[newWP].x, OnyxiaMoveData[newWP].y, OnyxiaMoveData[newWP].z);
} }
break; break;
@@ -510,9 +537,11 @@ public:
break; break;
case EVENT_ERUPTION: case EVENT_ERUPTION:
{ {
if( Creature* trigger = me->SummonCreature(12758, *me, TEMPSUMMON_TIMED_DESPAWN, 1000) ) if (Creature* trigger = me->SummonCreature(12758, *me, TEMPSUMMON_TIMED_DESPAWN, 1000))
{
trigger->CastSpell(trigger, 17731, false); trigger->CastSpell(trigger, 17731, false);
} }
}
break; break;
case EVENT_SUMMON_WHELP: case EVENT_SUMMON_WHELP:
{ {
@@ -528,10 +557,11 @@ public:
void SpellHitTarget(Unit* target, const SpellInfo* spell) override void SpellHitTarget(Unit* target, const SpellInfo* spell) override
{ {
if (target->GetTypeId() == TYPEID_PLAYER && spell->DurationEntry && spell->DurationEntry->ID == 328 && spell->Effects[EFFECT_1].TargetA.GetTarget() == 1 && (spell->Effects[EFFECT_1].Amplitude == 50 || spell->Effects[EFFECT_1].Amplitude == 215)) // Deep Breath if (target->IsPlayer() && spell->DurationEntry && spell->DurationEntry->ID == 328 && spell->Effects[EFFECT_1].TargetA.GetTarget() == 1 && (spell->Effects[EFFECT_1].Amplitude == 50 || spell->Effects[EFFECT_1].Amplitude == 215)) // Deep Breath
if (m_pInstance) {
m_pInstance->SetData(DATA_DEEP_BREATH_FAILED, 1); m_pInstance->SetData(DATA_DEEP_BREATH_FAILED, 1);
} }
}
}; };
}; };
@@ -558,24 +588,32 @@ public:
void MoveInLineOfSight(Unit* who) override void MoveInLineOfSight(Unit* who) override
{ {
if( me->GetVictim() || me->GetDistance(who) > 20.0f ) if (me->GetVictim() || me->GetDistance(who) > 20.0f)
{
return; return;
}
if( who->GetTypeId() == TYPEID_PLAYER ) if (who->GetTypeId() == TYPEID_PLAYER)
{
AttackStart(who); AttackStart(who);
} }
}
void UpdateAI(uint32 diff) override void UpdateAI(uint32 diff) override
{ {
if( !UpdateVictim() ) if (!UpdateVictim())
{
return; return;
}
events.Update(diff); events.Update(diff);
if( me->HasUnitState(UNIT_STATE_CASTING) ) if (me->HasUnitState(UNIT_STATE_CASTING))
{
return; return;
}
switch( events.ExecuteEvent() ) switch (events.ExecuteEvent())
{ {
case 0: case 0:
break; break;
@@ -585,7 +623,9 @@ public:
break; break;
case EVENT_OLG_SPELL_IGNITEWEAPON: case EVENT_OLG_SPELL_IGNITEWEAPON:
if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED)) if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED))
{
events.RepeatEvent(5000); events.RepeatEvent(5000);
}
else else
{ {
me->CastSpell(me, SPELL_OLG_IGNITEWEAPON, false); me->CastSpell(me, SPELL_OLG_IGNITEWEAPON, false);
@@ -595,9 +635,15 @@ public:
} }
if (!me->HasUnitState(UNIT_STATE_CASTING) && me->isAttackReady()) if (!me->HasUnitState(UNIT_STATE_CASTING) && me->isAttackReady())
{
if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED)) if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED))
{
if (me->HasAura(SPELL_OLG_IGNITEWEAPON)) if (me->HasAura(SPELL_OLG_IGNITEWEAPON))
{
me->RemoveAura(SPELL_OLG_IGNITEWEAPON); me->RemoveAura(SPELL_OLG_IGNITEWEAPON);
}
}
}
DoMeleeAttackIfReady(); DoMeleeAttackIfReady();
} }
@@ -620,12 +666,16 @@ public:
void MoveInLineOfSight(Unit* who) override void MoveInLineOfSight(Unit* who) override
{ {
if( me->GetVictim() || me->GetDistance(who) > 20.0f ) if (me->GetVictim() || me->GetDistance(who) > 20.0f)
{
return; return;
}
if( who->GetTypeId() == TYPEID_PLAYER ) if (who->GetTypeId() == TYPEID_PLAYER)
{
AttackStart(who); AttackStart(who);
} }
}
}; };
}; };
@@ -19,6 +19,11 @@
#include "ScriptedCreature.h" #include "ScriptedCreature.h"
#include "onyxias_lair.h" #include "onyxias_lair.h"
ObjectData const creatureData[] =
{
{ NPC_ONYXIA, DATA_ONYXIA }
};
class instance_onyxias_lair : public InstanceMapScript class instance_onyxias_lair : public InstanceMapScript
{ {
public: public:
@@ -33,7 +38,6 @@ public:
{ {
instance_onyxias_lair_InstanceMapScript(Map* pMap) : InstanceScript(pMap) {Initialize();}; instance_onyxias_lair_InstanceMapScript(Map* pMap) : InstanceScript(pMap) {Initialize();};
ObjectGuid m_uiOnyxiasGUID;
uint32 m_auiEncounter[MAX_ENCOUNTER]; uint32 m_auiEncounter[MAX_ENCOUNTER];
std::string str_data; std::string str_data;
uint16 ManyWhelpsCounter; uint16 ManyWhelpsCounter;
@@ -45,56 +49,53 @@ public:
memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
ManyWhelpsCounter = 0; ManyWhelpsCounter = 0;
bDeepBreath = true; bDeepBreath = true;
LoadObjectData(creatureData, nullptr);
} }
bool IsEncounterInProgress() const override void OnCreatureCreate(Creature* creature) override
{ {
for( uint8 i = 0; i < MAX_ENCOUNTER; ++i ) switch (creature->GetEntry())
if( m_auiEncounter[i] == IN_PROGRESS )
return true;
return false;
}
void OnCreatureCreate(Creature* pCreature) override
{ {
switch( pCreature->GetEntry() )
{
case NPC_ONYXIA:
m_uiOnyxiasGUID = pCreature->GetGUID();
break;
case NPC_ONYXIAN_WHELP: case NPC_ONYXIAN_WHELP:
case NPC_ONYXIAN_LAIR_GUARD: case NPC_ONYXIAN_LAIR_GUARD:
minions.push_back(pCreature->GetGUID()); minions.push_back(creature->GetGUID());
break; break;
} }
InstanceScript::OnCreatureCreate(creature);
} }
void OnGameObjectCreate(GameObject* go) override void OnGameObjectCreate(GameObject* go) override
{ {
switch( go->GetEntry() ) switch (go->GetEntry())
{ {
case GO_WHELP_SPAWNER: case GO_WHELP_SPAWNER:
go->CastSpell((Unit*)nullptr, 17646); go->CastSpell((Unit*)nullptr, 17646);
if( Creature* onyxia = instance->GetCreature(m_uiOnyxiasGUID) ) if (Creature* onyxia = GetCreature(DATA_ONYXIA))
{
onyxia->AI()->DoAction(-1); onyxia->AI()->DoAction(-1);
}
break; break;
} }
} }
void SetData(uint32 uiType, uint32 uiData) override void SetData(uint32 uiType, uint32 uiData) override
{ {
switch(uiType) switch (uiType)
{ {
case DATA_ONYXIA: case DATA_ONYXIA:
m_auiEncounter[0] = uiData; m_auiEncounter[0] = uiData;
ManyWhelpsCounter = 0; ManyWhelpsCounter = 0;
bDeepBreath = true; bDeepBreath = true;
if( uiData == NOT_STARTED ) if(uiData == NOT_STARTED)
{ {
for (ObjectGuid const& guid : minions) for (ObjectGuid const& guid : minions)
{
if (Creature* c = instance->GetCreature(guid)) if (Creature* c = instance->GetCreature(guid))
{
c->DespawnOrUnsummon(); c->DespawnOrUnsummon();
}
}
minions.clear(); minions.clear();
} }
break; break;
@@ -107,12 +108,14 @@ public:
} }
if (uiType < MAX_ENCOUNTER && uiData == DONE) if (uiType < MAX_ENCOUNTER && uiData == DONE)
{
SaveToDB(); SaveToDB();
} }
}
uint32 GetData(uint32 uiType) const override uint32 GetData(uint32 uiType) const override
{ {
switch(uiType) switch (uiType)
{ {
case DATA_ONYXIA: case DATA_ONYXIA:
return m_auiEncounter[0]; return m_auiEncounter[0];
@@ -121,17 +124,6 @@ public:
return 0; return 0;
} }
ObjectGuid GetGuidData(uint32 uiData) const override
{
switch (uiData)
{
case DATA_ONYXIA:
return m_uiOnyxiasGUID;
}
return ObjectGuid::Empty;
}
std::string GetSaveData() override std::string GetSaveData() override
{ {
OUT_SAVE_INST_DATA; OUT_SAVE_INST_DATA;