Scripts/VioletHold: Fix codestyle and unwanted crash in Violet/Hold

closes #14952 and #14953
This commit is contained in:
mik1893
2015-06-26 00:30:04 +02:00
parent e34f74dace
commit 49809bd404
7 changed files with 66 additions and 71 deletions

View File

@@ -57,16 +57,21 @@ class boss_erekem : public CreatureScript
public:
boss_erekem() : CreatureScript("boss_erekem") { }
CreatureAI* GetAI(Creature* creature) const override
{
return GetInstanceAI<boss_erekemAI>(creature);
}
struct boss_erekemAI : public ScriptedAI
{
boss_erekemAI(Creature* creature) : ScriptedAI(creature)
{
Initialize();
instance = creature->GetInstanceScript();
}
void Initialize()
{
events.Reset();
phase = 0;
breakBondsCd = 0;
}
@@ -100,6 +105,8 @@ public:
pGuard2->Respawn();
}
}
events.Reset();
}
void JustReachedHome() override
@@ -297,11 +304,6 @@ public:
uint8 phase;
int32 breakBondsCd;
};
CreatureAI* GetAI(Creature* creature) const override
{
return GetInstanceAI<boss_erekemAI>(creature);
}
};
enum GuardSpells
@@ -316,6 +318,11 @@ class npc_erekem_guard : public CreatureScript
public:
npc_erekem_guard() : CreatureScript("npc_erekem_guard") { }
CreatureAI* GetAI(Creature* creature) const override
{
return GetInstanceAI<npc_erekem_guardAI>(creature);
}
struct npc_erekem_guardAI : public ScriptedAI
{
npc_erekem_guardAI(Creature* creature) : ScriptedAI(creature)
@@ -387,11 +394,6 @@ public:
} else uiGushingWoundTimer -= diff;
}
};
CreatureAI* GetAI(Creature* creature) const override
{
return GetInstanceAI<npc_erekem_guardAI>(creature);
}
};
void AddSC_boss_erekem()

View File

@@ -72,7 +72,10 @@ enum Misc
DATA_DEHYDRATION = 1
};
Position const globulePaths[10] =
#define MAX_GLOBULE_PATHS 10
Position const globulePaths[MAX_GLOBULE_PATHS] =
{
// first target
{ 1861.357f, 804.039f, 44.008f, 6.268f },
@@ -177,9 +180,7 @@ public:
DoExplodeCompleted();
me->SetHealth(me->GetHealth() + me->CountPctFromMaxHealth(3));
if (dehydration)
dehydration = false;
dehydration = false;
}
break;
}
@@ -314,7 +315,7 @@ public:
GetCreatureListWithEntryInGrid(summonTargets, me, NPC_ICHORON_SUMMON_TARGET, 200.0f);
std::list<Creature*>::iterator itr = summonTargets.begin();
for (uint8 i = 0; i < 10; i++)
for (uint8 i = 0; i < MAX_GLOBULE_PATHS; i++)
{
std::advance(itr, urand(0, summonTargets.size() - 1)); // I take a random minion in the list
Position targetPos = (*itr)->GetRandomNearPosition(10.0f);
@@ -325,7 +326,7 @@ public:
float minDistance = 1000.0f;
uint8 nextPath = 0;
// I move the globules to next position. the 10 positions are in couples, defined in globulePaths, so i have to increase by 2.
for (uint8 gpath = 0; gpath < 10; gpath += 2)
for (uint8 gpath = 0; gpath < MAX_GLOBULE_PATHS; gpath += 2)
{
if (globule->GetDistance(globulePaths[gpath]) < minDistance)
{
@@ -441,20 +442,22 @@ public:
{
npc_ichor_globuleAI(Creature* creature) : ScriptedAI(creature)
{
Initialize();
instance = creature->GetInstanceScript();
}
void Initialize()
{
pathId = 0;
}
void Reset() override
{
pathId = 0;
Initialize();
events.Reset();
DoCast(SPELL_WATER_GLOBULE);
}
void AttackStart(Unit* /*who*/) override
{
}
void SetData(uint32 id, uint32 data) override
{
if (id == DATA_GLOBULE_PATH)

View File

@@ -40,6 +40,11 @@ class boss_lavanthor : public CreatureScript
public:
boss_lavanthor() : CreatureScript("boss_lavanthor") { }
CreatureAI* GetAI(Creature* creature) const override
{
return GetInstanceAI<boss_lavanthorAI>(creature);
}
struct boss_lavanthorAI : public ScriptedAI
{
boss_lavanthorAI(Creature* creature) : ScriptedAI(creature)
@@ -146,11 +151,6 @@ public:
EventMap events;
InstanceScript* instance;
};
CreatureAI* GetAI(Creature* creature) const override
{
return GetInstanceAI<boss_lavanthorAI>(creature);
}
};
void AddSC_boss_lavanthor()

View File

@@ -163,7 +163,7 @@ public:
void OnPeriodic(AuraEffect const* aurEff)
{
PreventDefaultAction();
std::list<HostileReference*> players = GetTarget()->ToCreature()->getThreatManager().getThreatList();
std::list<HostileReference*> players = GetTarget()->getThreatManager().getThreatList();
if (!players.empty())
{
std::list<HostileReference*>::iterator itr = players.begin();
@@ -198,7 +198,7 @@ public:
void OnPeriodic(AuraEffect const* aurEff)
{
PreventDefaultAction();
std::list<HostileReference*> players = GetTarget()->ToCreature()->getThreatManager().getThreatList();
std::list<HostileReference*> players = GetTarget()->getThreatManager().getThreatList();
if (!players.empty())
{
std::list<HostileReference*>::iterator itr = players.begin();

View File

@@ -68,6 +68,11 @@ enum XevozzEvents
EVENT_DESPAWN_SPHERE
};
enum SphereActions
{
ACTION_SUMMON = 1,
};
class boss_xevozz : public CreatureScript
{
public:
@@ -216,9 +221,9 @@ public:
break;
case EVENT_SUMMON_PLAYERS:
if (Creature* sphere = me->FindNearestCreature(NPC_ETHEREAL_SPHERE, 150.0f))
sphere->GetAI()->DoAction(1);
sphere->GetAI()->DoAction(ACTION_SUMMON);
else if (Creature* sphere = me->FindNearestCreature(NPC_ETHEREAL_SPHERE2, 150.0f))
sphere->GetAI()->DoAction(1);
sphere->GetAI()->DoAction(ACTION_SUMMON);
break;
default:
break;
@@ -247,25 +252,31 @@ public:
{
npc_ethereal_sphereAI(Creature* creature) : ScriptedAI(creature)
{
Initialize();
instance = creature->GetInstanceScript();
}
void Initialize()
{
arcanePower = false;
}
void Reset() override
{
Initialize();
events.Reset();
DoCast(SPELL_POWER_BALL_VISUAL);
DoCast(SPELL_POWER_BALL_DAMAGE_TRIGGER);
arcanePower = false;
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
me->setFaction(16);
events.ScheduleEvent(EVENT_DESPAWN_SPHERE, 40000);
events.ScheduleEvent(EVENT_RANGE_CHECK, 1000);
}
void DoAction(int32 action) override
{
DoCast(SPELL_SUMMON_PLAYERS);
if (action == ACTION_SUMMON)
DoCast(SPELL_SUMMON_PLAYERS);
}
void UpdateAI(uint32 diff) override
@@ -316,7 +327,7 @@ public:
{
PrepareSpellScript(spell_xevozz_summon_players_SpellScript);
void HandleScript(SpellEffIndex effIndex)
void HandleScript(SpellEffIndex /*effIndex*/)
{
Unit* target = GetHitUnit();

View File

@@ -58,26 +58,23 @@ public:
{
boss_zuramatAI(Creature* creature) : ScriptedAI(creature), sentries(me)
{
Initialize();
instance = creature->GetInstanceScript();
}
void Initialize()
{
events.Reset();
voidDance = true;
}
void DespawnSentries()
{
sentries.DespawnAll();
std::list<Creature*> sentries;
GetCreatureListWithEntryInGrid(sentries, me, NPC_VOID_SENTRY_BALL, 200.0f);
if (!sentries.empty())
{
std::list<Creature*>::iterator itr = sentries.begin();
for (itr; itr != sentries.end(); ++itr)
std::list<Creature*> sentrylist;
GetCreatureListWithEntryInGrid(sentrylist, me, NPC_VOID_SENTRY_BALL, 200.0f);
if (!sentrylist.empty())
for (std::list<Creature*>::const_iterator itr = sentrylist.begin(); itr != sentrylist.end(); ++itr)
(*itr)->DespawnOrUnsummon();
}
}
void Reset() override
@@ -88,6 +85,7 @@ public:
instance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
Initialize();
events.Reset();
DespawnSentries();
}
@@ -174,7 +172,6 @@ public:
void UpdateAI(uint32 diff) override
{
//Return since we have no target
if (!UpdateVictim())
return;

View File

@@ -250,7 +250,9 @@ const Position PortalLocation[] =
{ 1890.64f, 753.471f, 48.7224f, 1.71042f }, // WP 5
};
uint64 preEventPortalGUID[3] = { 0 };
#define MAX_PRE_EVENT_PORTAL 3
ObjectGuid preEventPortalGUID[MAX_PRE_EVENT_PORTAL] = { ObjectGuid::Empty };
const Position MovePosition = { 1806.955566f, 803.851807f, 44.363323f, 0.0f };
const Position playerTeleportPosition = { 1830.531006f, 803.939758f, 44.340508f, 6.281611f };
@@ -331,13 +333,9 @@ public:
Initialize();
me->SetReactState(REACT_AGGRESSIVE);
if (TempSummon* summon = me->SummonCreature(NPC_TELEPORTATION_PORTAL, PortalLocation[0], TEMPSUMMON_MANUAL_DESPAWN))
preEventPortalGUID[0] = summon->GetGUID();
if (TempSummon* summon = me->SummonCreature(NPC_TELEPORTATION_PORTAL, PortalLocation[1], TEMPSUMMON_MANUAL_DESPAWN))
preEventPortalGUID[1] = summon->GetGUID();
if (TempSummon* summon = me->SummonCreature(NPC_TELEPORTATION_PORTAL, PortalLocation[2], TEMPSUMMON_MANUAL_DESPAWN))
preEventPortalGUID[2] = summon->GetGUID();
for (uint8 i = 0; i < MAX_PRE_EVENT_PORTAL; i++)
if (TempSummon* summon = me->SummonCreature(NPC_TELEPORTATION_PORTAL, PortalLocation[i], TEMPSUMMON_MANUAL_DESPAWN))
preEventPortalGUID[i] = summon->GetGUID();
std::list<Creature*> GuardList;
me->GetCreatureListWithEntryInGrid(GuardList, NPC_VIOLET_HOLD_GUARD, 40.0f);
@@ -758,26 +756,10 @@ struct violet_hold_trashAI : public npc_escortAI
{
if (Creature* portal = me->FindNearestCreature(NPC_TELEPORTATION_PORTAL, 10.0f))
{
uint64 portalGUID = portal->GetGUID();
for (uint8 i = 0; i < 3; i++)
{
ObjectGuid portalGUID = portal->GetGUID();
for (uint8 i = 0; i < MAX_PRE_EVENT_PORTAL; i++)
if (portalGUID == preEventPortalGUID[i])
{
switch (i)
{
case 0:
portalLocationID = 0;
break;
case 1:
portalLocationID = 2;
break;
case 2:
portalLocationID = 4;
break;
}
break;
}
}
portalLocationID = i * 2;
}
}
else