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
{
if (me->GetVictim() || me->GetDistance(who) > 30.0f)
{
return;
}
if (who->GetTypeId() == TYPEID_PLAYER)
{
AttackStart(who);
}
}
void DoAction(int32 param) override
{
@@ -195,7 +204,9 @@ public:
{
case -1:
if (bManyWhelpsAvailable && m_pInstance)
{
m_pInstance->SetData(DATA_WHELP_SUMMONED, 1);
}
break;
}
}
@@ -220,19 +231,15 @@ public:
BindPlayers();
}
void JustDied(Unit* /*killer*/) override
{
if( m_pInstance )
m_pInstance->SetData(DATA_ONYXIA, DONE);
}
void DamageTaken(Unit*, uint32& /*damage*/, DamageEffectType, SpellSchoolMask) override
{
switch (Phase)
{
case 1:
if (me->GetHealth() * 100 / me->GetMaxHealth() <= 65)
{
SetPhase(2);
}
break;
case 2:
if (me->GetHealth() * 100 / me->GetMaxHealth() <= 40)
@@ -246,10 +253,11 @@ public:
void JustSummoned(Creature* pSummoned) override
{
if( !pSummoned )
return;
if (pSummoned->GetEntry() != NPC_ONYXIAN_WHELP && pSummoned->GetEntry() != NPC_ONYXIAN_LAIR_GUARD)
{
return;
}
if (Unit* target = pSummoned->SelectNearestTarget(300.0f))
{
pSummoned->AI()->AttackStart(target);
@@ -260,7 +268,9 @@ public:
void MovementInform(uint32 type, uint32 id) override
{
if (type != POINT_MOTION_TYPE && type != EFFECT_MOTION_TYPE)
{
return;
}
if (id < 9)
{
@@ -272,7 +282,9 @@ public:
events.ScheduleEvent(EVENT_SPELL_FIREBALL_FIRST, 1000);
}
}
else switch( id )
else
{
switch (id)
{
case 10:
me->SetFacingTo(OnyxiaMoveData[0].o);
@@ -294,6 +306,7 @@ public:
break;
}
}
}
void HandleWhelpSpam(const uint32 diff)
{
@@ -324,13 +337,17 @@ public:
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
{
return;
}
events.Update(diff);
HandleWhelpSpam(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
{
return;
}
DoMeleeAttackIfReady();
@@ -441,18 +458,26 @@ public:
uint8 rand = urand(0, 99);
if (rand < 33)
{
events.ScheduleEvent(EVENT_PHASE_2_STEP_CW, 4000);
}
else if (rand < 66)
{
events.ScheduleEvent(EVENT_PHASE_2_STEP_ACW, 4000);
}
else
{
events.ScheduleEvent(EVENT_PHASE_2_STEP_ACROSS, 4000);
}
}
break;
case EVENT_PHASE_2_STEP_CW:
{
uint8 newWP = CurrentWP + 1;
if (newWP > 8)
{
newWP = 1;
}
me->GetMotionMaster()->MovePoint(newWP, OnyxiaMoveData[newWP].x, OnyxiaMoveData[newWP].y, OnyxiaMoveData[newWP].z);
}
break;
@@ -460,7 +485,9 @@ public:
{
uint8 newWP = CurrentWP - 1;
if (newWP < 1)
{
newWP = 8;
}
me->GetMotionMaster()->MovePoint(newWP, OnyxiaMoveData[newWP].x, OnyxiaMoveData[newWP].y, OnyxiaMoveData[newWP].z);
}
break;
@@ -511,8 +538,10 @@ public:
case EVENT_ERUPTION:
{
if (Creature* trigger = me->SummonCreature(12758, *me, TEMPSUMMON_TIMED_DESPAWN, 1000))
{
trigger->CastSpell(trigger, 17731, false);
}
}
break;
case EVENT_SUMMON_WHELP:
{
@@ -528,10 +557,11 @@ public:
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 (m_pInstance)
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
{
m_pInstance->SetData(DATA_DEEP_BREATH_FAILED, 1);
}
}
};
};
@@ -559,21 +589,29 @@ public:
void MoveInLineOfSight(Unit* who) override
{
if (me->GetVictim() || me->GetDistance(who) > 20.0f)
{
return;
}
if (who->GetTypeId() == TYPEID_PLAYER)
{
AttackStart(who);
}
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
{
return;
}
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
{
return;
}
switch (events.ExecuteEvent())
{
@@ -585,7 +623,9 @@ public:
break;
case EVENT_OLG_SPELL_IGNITEWEAPON:
if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED))
{
events.RepeatEvent(5000);
}
else
{
me->CastSpell(me, SPELL_OLG_IGNITEWEAPON, false);
@@ -595,9 +635,15 @@ public:
}
if (!me->HasUnitState(UNIT_STATE_CASTING) && me->isAttackReady())
{
if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED))
{
if (me->HasAura(SPELL_OLG_IGNITEWEAPON))
{
me->RemoveAura(SPELL_OLG_IGNITEWEAPON);
}
}
}
DoMeleeAttackIfReady();
}
@@ -621,11 +667,15 @@ public:
void MoveInLineOfSight(Unit* who) override
{
if (me->GetVictim() || me->GetDistance(who) > 20.0f)
{
return;
}
if (who->GetTypeId() == TYPEID_PLAYER)
{
AttackStart(who);
}
}
};
};
@@ -19,6 +19,11 @@
#include "ScriptedCreature.h"
#include "onyxias_lair.h"
ObjectData const creatureData[] =
{
{ NPC_ONYXIA, DATA_ONYXIA }
};
class instance_onyxias_lair : public InstanceMapScript
{
public:
@@ -33,7 +38,6 @@ public:
{
instance_onyxias_lair_InstanceMapScript(Map* pMap) : InstanceScript(pMap) {Initialize();};
ObjectGuid m_uiOnyxiasGUID;
uint32 m_auiEncounter[MAX_ENCOUNTER];
std::string str_data;
uint16 ManyWhelpsCounter;
@@ -45,29 +49,20 @@ public:
memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
ManyWhelpsCounter = 0;
bDeepBreath = true;
LoadObjectData(creatureData, nullptr);
}
bool IsEncounterInProgress() const override
void OnCreatureCreate(Creature* creature) override
{
for( uint8 i = 0; i < MAX_ENCOUNTER; ++i )
if( m_auiEncounter[i] == IN_PROGRESS )
return true;
return false;
}
void OnCreatureCreate(Creature* pCreature) override
switch (creature->GetEntry())
{
switch( pCreature->GetEntry() )
{
case NPC_ONYXIA:
m_uiOnyxiasGUID = pCreature->GetGUID();
break;
case NPC_ONYXIAN_WHELP:
case NPC_ONYXIAN_LAIR_GUARD:
minions.push_back(pCreature->GetGUID());
minions.push_back(creature->GetGUID());
break;
}
InstanceScript::OnCreatureCreate(creature);
}
void OnGameObjectCreate(GameObject* go) override
@@ -76,8 +71,10 @@ public:
{
case GO_WHELP_SPAWNER:
go->CastSpell((Unit*)nullptr, 17646);
if( Creature* onyxia = instance->GetCreature(m_uiOnyxiasGUID) )
if (Creature* onyxia = GetCreature(DATA_ONYXIA))
{
onyxia->AI()->DoAction(-1);
}
break;
}
}
@@ -93,8 +90,12 @@ public:
if(uiData == NOT_STARTED)
{
for (ObjectGuid const& guid : minions)
{
if (Creature* c = instance->GetCreature(guid))
{
c->DespawnOrUnsummon();
}
}
minions.clear();
}
break;
@@ -107,8 +108,10 @@ public:
}
if (uiType < MAX_ENCOUNTER && uiData == DONE)
{
SaveToDB();
}
}
uint32 GetData(uint32 uiType) const override
{
@@ -121,17 +124,6 @@ public:
return 0;
}
ObjectGuid GetGuidData(uint32 uiData) const override
{
switch (uiData)
{
case DATA_ONYXIA:
return m_uiOnyxiasGUID;
}
return ObjectGuid::Empty;
}
std::string GetSaveData() override
{
OUT_SAVE_INST_DATA;