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
@@ -180,14 +180,23 @@ public:
} }
} }
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
{ {
@@ -195,7 +204,9 @@ public:
{ {
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;
} }
} }
@@ -220,19 +231,15 @@ 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)
@@ -246,10 +253,11 @@ public:
void JustSummoned(Creature* pSummoned) override void JustSummoned(Creature* pSummoned) override
{ {
if( !pSummoned )
return;
if (pSummoned->GetEntry() != NPC_ONYXIAN_WHELP && pSummoned->GetEntry() != NPC_ONYXIAN_LAIR_GUARD) if (pSummoned->GetEntry() != NPC_ONYXIAN_WHELP && pSummoned->GetEntry() != NPC_ONYXIAN_LAIR_GUARD)
{
return; return;
}
if (Unit* target = pSummoned->SelectNearestTarget(300.0f)) if (Unit* target = pSummoned->SelectNearestTarget(300.0f))
{ {
pSummoned->AI()->AttackStart(target); pSummoned->AI()->AttackStart(target);
@@ -260,7 +268,9 @@ 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; return;
}
if (id < 9) if (id < 9)
{ {
@@ -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,6 +306,7 @@ public:
break; break;
} }
} }
}
void HandleWhelpSpam(const uint32 diff) void HandleWhelpSpam(const uint32 diff)
{ {
@@ -324,13 +337,17 @@ 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();
@@ -441,18 +458,26 @@ public:
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;
@@ -460,7 +485,9 @@ public:
{ {
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;
@@ -511,8 +538,10 @@ public:
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);
} }
}
}; };
}; };
@@ -559,21 +589,29 @@ 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())
{ {
@@ -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();
} }
@@ -621,11 +667,15 @@ 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,29 +49,20 @@ 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
@@ -76,8 +71,10 @@ public:
{ {
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;
} }
} }
@@ -93,8 +90,12 @@ public:
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,8 +108,10 @@ 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
{ {
@@ -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;