Use GUIDs instead of "global" pointers in zone scripts.

This commit is like that: 7714 / rce505237e4aa

And use const_iterators where it is possible.

--HG--
branch : trunk
This commit is contained in:
Anubisss
2010-04-02 15:41:37 +02:00
parent 7c4f2f520f
commit 08b4748e62
85 changed files with 289 additions and 256 deletions
@@ -205,7 +205,7 @@ struct boss_volazjAI : public ScriptedAI
Summons.Despawn(summon);
// Check if all summons in this phase killed
for(SummonList::const_iterator iter = Summons.begin(); iter!=Summons.end(); iter++)
for(SummonList::const_iterator iter = Summons.begin(); iter!=Summons.end(); ++iter)
{
if(Creature *visage = Unit::GetCreature(*m_creature, *iter))
{
@@ -209,7 +209,7 @@ struct boss_taldaramAI : public ScriptedAI
Unit *pTarget = NULL;
std::list<HostileReference *> t_list = m_creature->getThreatManager().getThreatList();
std::vector<Unit *> target_list;
for (std::list<HostileReference *>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
for (std::list<HostileReference *>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
{
pTarget = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
// exclude pets & totems
@@ -131,7 +131,7 @@ struct boss_black_knightAI : public ScriptedAI
if (SummonList.empty())
return;
for(std::list<uint64>::iterator itr = SummonList.begin(); itr != SummonList.end(); ++itr)
for(std::list<uint64>::const_iterator itr = SummonList.begin(); itr != SummonList.end(); ++itr)
{
if (Creature* pTemp = Unit::GetCreature(*m_creature, *itr))
if (pTemp)
@@ -171,7 +171,7 @@ struct instance_trial_of_the_champion : public ScriptedInstance
m_auiEncounter[0] = uiData;
if (uiData == IN_PROGRESS)
{
for(std::list<uint64>::iterator itr = VehicleList.begin(); itr != VehicleList.end(); ++itr)
for(std::list<uint64>::const_iterator itr = VehicleList.begin(); itr != VehicleList.end(); ++itr)
if (Creature* pSummon = instance->GetCreature(*itr))
pSummon->RemoveFromWorld();
}else if (uiData == DONE)
@@ -141,7 +141,7 @@ struct npc_announcer_toc5AI : public ScriptedAI
break;
}
for(std::list<uint64>::iterator itr = TempList.begin(); itr != TempList.end(); ++itr)
for(std::list<uint64>::const_iterator itr = TempList.begin(); itr != TempList.end(); ++itr)
if (Creature* pSummon = Unit::GetCreature(*m_creature, *itr))
AggroAllPlayers(pSummon);
}else if (uiLesserChampions == 9)
@@ -416,7 +416,7 @@ struct npc_announcer_toc5AI : public ScriptedAI
case 3:
if (!Champion1List.empty())
{
for(std::list<uint64>::iterator itr = Champion1List.begin(); itr != Champion1List.end(); ++itr)
for(std::list<uint64>::const_iterator itr = Champion1List.begin(); itr != Champion1List.end(); ++itr)
if (Creature* pSummon = Unit::GetCreature(*m_creature, *itr))
AggroAllPlayers(pSummon);
NextStep(0,false);
+4 -2
View File
@@ -48,7 +48,6 @@ struct npc_warmage_violetstandAI : public Scripted_NoMovementAI
npc_warmage_violetstandAI(Creature* pCreature) : Scripted_NoMovementAI(pCreature){}
uint32 m_uiTimer; //Timer until recast
std::list<Creature *> orbList;
void Reset()
{
@@ -69,10 +68,12 @@ struct npc_warmage_violetstandAI : public Scripted_NoMovementAI
switch(me->GetEntry())
{
case NPC_WARMAGE_SARINA:
{
std::list<Creature*> orbList;
GetCreatureListWithEntryInGrid(orbList, m_creature, NPC_TRANSITUS_SHIELD_DUMMY, 32.0f);
if (!orbList.empty())
{
for (std::list<Creature*>::iterator itr = orbList.begin(); itr != orbList.end(); ++itr)
for (std::list<Creature*>::const_iterator itr = orbList.begin(); itr != orbList.end(); ++itr)
{
if (Creature* pOrb = *itr)
if (pOrb->GetPositionY() < 1000)
@@ -80,6 +81,7 @@ struct npc_warmage_violetstandAI : public Scripted_NoMovementAI
}
}
m_uiTimer = 90000;
}
break;
case NPC_WARMAGE_HALISTER:
case NPC_WARMAGE_ILSUDRIA:
@@ -106,7 +106,7 @@ struct boss_novosAI : public Scripted_NoMovementAI
luiCrystals.push_back(pInstance->GetData64(DATA_NOVOS_CRYSTAL_2));
luiCrystals.push_back(pInstance->GetData64(DATA_NOVOS_CRYSTAL_3));
luiCrystals.push_back(pInstance->GetData64(DATA_NOVOS_CRYSTAL_4));
for (std::list<uint64>::iterator itr = luiCrystals.begin(); itr != luiCrystals.end(); ++itr)
for (std::list<uint64>::const_iterator itr = luiCrystals.begin(); itr != luiCrystals.end(); ++itr)
{
if (GameObject* pTemp = pInstance->instance->GetGameObject(*itr))
pTemp->SetGoState(GO_STATE_READY);
@@ -123,7 +123,7 @@ struct boss_novosAI : public Scripted_NoMovementAI
DoCast(SPELL_ARCANE_FIELD);
if (pInstance)
{
for (std::list<uint64>::iterator itr = luiCrystals.begin(); itr != luiCrystals.end(); ++itr)
for (std::list<uint64>::const_iterator itr = luiCrystals.begin(); itr != luiCrystals.end(); ++itr)
{
if (GameObject *pTemp = pInstance->instance->GetGameObject(*itr))
pTemp->SetGoState(GO_STATE_ACTIVE);
@@ -147,7 +147,7 @@ struct boss_tharon_jaAI : public ScriptedAI
DoScriptText(RAND(SAY_FLESH_1,SAY_FLESH_2),m_creature);
m_creature->SetDisplayId(MODEL_FLESH);
std::list<HostileReference*>& threatlist = m_creature->getThreatManager().getThreatList();
for (std::list<HostileReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
for (std::list<HostileReference*>::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
{
Unit *pTemp = Unit::GetUnit((*m_creature),(*itr)->getUnitGuid());
if (pTemp && pTemp->GetTypeId() == TYPEID_PLAYER)
@@ -203,7 +203,7 @@ struct boss_tharon_jaAI : public ScriptedAI
uiRainOfFireTimer = urand(14*IN_MILISECONDS,18*IN_MILISECONDS);
uiShadowVolleyTimer = urand(8*IN_MILISECONDS,10*IN_MILISECONDS);
std::list<HostileReference*>& threatlist = m_creature->getThreatManager().getThreatList();
for (std::list<HostileReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
for (std::list<HostileReference*>::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
{
Unit *pTemp = Unit::GetUnit((*m_creature),(*itr)->getUnitGuid());
if (pTemp && pTemp->GetTypeId() == TYPEID_PLAYER)
+62 -56
View File
@@ -150,17 +150,14 @@ enum eFloppy
struct npc_emilyAI : public npc_escortAI
{
npc_emilyAI(Creature* pCreature) : npc_escortAI(pCreature) { }
uint32 m_uiChatTimer;
uint64 RWORGGUID;
uint64 MrfloppyGUID;
Creature* Mrfloppy;
Creature* RWORG;
bool Completed;
void JustSummoned(Creature* pSummoned)
{
if (Creature* Mrfloppy = GetClosestCreatureWithEntry(m_creature, NPC_MRFLOPPY, 50.0f))
@@ -168,7 +165,7 @@ struct npc_emilyAI : public npc_escortAI
else
pSummoned->AI()->AttackStart(m_creature->getVictim());
}
void WaypointReached(uint32 i)
{
Player* pPlayer = GetPlayerForEscort();
@@ -177,57 +174,77 @@ struct npc_emilyAI : public npc_escortAI
switch (i)
{
case 9:
Mrfloppy = GetClosestCreatureWithEntry(m_creature, NPC_MRFLOPPY, 100.0f);
if (Creature *Mrfloppy = GetClosestCreatureWithEntry(m_creature, NPC_MRFLOPPY, 100.0f))
MrfloppyGUID = Mrfloppy->GetGUID();
break;
case 10:
if (Mrfloppy)
if (Creature *Mrfloppy = Unit::GetCreature(*m_creature, MrfloppyGUID))
{
DoScriptText(SAY_WORGHAGGRO1, m_creature);
m_creature->SummonCreature(NPC_HUNGRY_WORG,m_creature->GetPositionX()+5,m_creature->GetPositionY()+2,m_creature->GetPositionZ()+1,3.229f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,120000);
}
break;
case 11:
Mrfloppy->GetMotionMaster()->MoveFollow(m_creature, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
if (Creature *Mrfloppy = Unit::GetCreature(*m_creature, MrfloppyGUID))
Mrfloppy->GetMotionMaster()->MoveFollow(m_creature, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
break;
case 17:
Mrfloppy->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ());
if (Creature *Mrfloppy = Unit::GetCreature(*m_creature, MrfloppyGUID))
Mrfloppy->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ());
DoScriptText(SAY_WORGRAGGRO3, m_creature);
RWORG = m_creature->SummonCreature(NPC_RAVENOUS_WORG,m_creature->GetPositionX()+10,m_creature->GetPositionY()+8,m_creature->GetPositionZ()+2,3.229f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,120000);
RWORG->setFaction(35);
if (Creature *RWORG = m_creature->SummonCreature(NPC_RAVENOUS_WORG,m_creature->GetPositionX()+10,m_creature->GetPositionY()+8,m_creature->GetPositionZ()+2,3.229f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,120000))
{
RWORG->setFaction(35);
RWORGGUID = RWORG->GetGUID();
}
break;
case 18:
if (Mrfloppy)
if (Creature *Mrfloppy = Unit::GetCreature(*m_creature, MrfloppyGUID))
{
RWORG->GetMotionMaster()->MovePoint(0, Mrfloppy->GetPositionX(), Mrfloppy->GetPositionY(), Mrfloppy->GetPositionZ());
if (Creature *RWORG = Unit::GetCreature(*m_creature, RWORGGUID))
RWORG->GetMotionMaster()->MovePoint(0, Mrfloppy->GetPositionX(), Mrfloppy->GetPositionY(), Mrfloppy->GetPositionZ());
DoCast(Mrfloppy,SPELL_MRFLOPPY);
}
break;
case 19:
if (Mrfloppy->HasAura(SPELL_MRFLOPPY, 0))
Mrfloppy->EnterVehicle(RWORG);
if (Creature *Mrfloppy = Unit::GetCreature(*m_creature, MrfloppyGUID))
{
if (Mrfloppy->HasAura(SPELL_MRFLOPPY, 0))
{
if (Creature *RWORG = Unit::GetCreature(*m_creature, RWORGGUID))
Mrfloppy->EnterVehicle(RWORG);
}
}
break;
case 20:
if (Mrfloppy)
if (Creature *RWORG = Unit::GetCreature(*m_creature, RWORGGUID))
RWORG->HandleEmoteCommand(34);
break;
case 21:
if (Mrfloppy)
if (Creature *Mrfloppy = Unit::GetCreature(*m_creature, MrfloppyGUID))
{
RWORG->Kill(Mrfloppy);
Mrfloppy->ExitVehicle();
RWORG->setFaction(14);
RWORG->GetMotionMaster()->MovePoint(0, RWORG->GetPositionX()+10,RWORG->GetPositionY()+80,RWORG->GetPositionZ());
DoScriptText(SAY_VICTORY2, m_creature);
if (Creature *RWORG = Unit::GetCreature(*m_creature, RWORGGUID))
{
RWORG->Kill(Mrfloppy);
Mrfloppy->ExitVehicle();
RWORG->setFaction(14);
RWORG->GetMotionMaster()->MovePoint(0, RWORG->GetPositionX()+10,RWORG->GetPositionY()+80,RWORG->GetPositionZ());
DoScriptText(SAY_VICTORY2, m_creature);
}
}
break;
case 22:
if (Mrfloppy && Mrfloppy->isDead())
if (Creature *Mrfloppy = Unit::GetCreature(*m_creature, MrfloppyGUID))
{
RWORG->DisappearAndDie();
m_creature->GetMotionMaster()->MovePoint(0, Mrfloppy->GetPositionX(), Mrfloppy->GetPositionY(), Mrfloppy->GetPositionZ());
Mrfloppy->setDeathState(ALIVE);
Mrfloppy->GetMotionMaster()->MoveFollow(m_creature, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
DoScriptText(SAY_VICTORY3, m_creature);
if (Mrfloppy->isDead())
{
if (Creature *RWORG = Unit::GetCreature(*m_creature, RWORGGUID))
RWORG->DisappearAndDie();
m_creature->GetMotionMaster()->MovePoint(0, Mrfloppy->GetPositionX(), Mrfloppy->GetPositionY(), Mrfloppy->GetPositionZ());
Mrfloppy->setDeathState(ALIVE);
Mrfloppy->GetMotionMaster()->MoveFollow(m_creature, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
DoScriptText(SAY_VICTORY3, m_creature);
}
}
break;
case 24:
@@ -244,28 +261,28 @@ struct npc_emilyAI : public npc_escortAI
break;
case 27:
m_creature->DisappearAndDie();
if (Mrfloppy)
if (Creature *Mrfloppy = Unit::GetCreature(*m_creature, MrfloppyGUID))
Mrfloppy->DisappearAndDie();
break;
}
}
void EnterCombat(Unit* Who)
{
DoScriptText(SAY_RANDOMAGGRO, m_creature);
}
void Reset()
{
m_uiChatTimer = 4000;
Mrfloppy = NULL;
RWORG = NULL;
MrfloppyGUID = 0;
RWORGGUID = 0;
}
void UpdateAI(const uint32 uiDiff)
{
npc_escortAI::UpdateAI(uiDiff);
if (HasEscortState(STATE_ESCORT_ESCORTING))
{
if (m_uiChatTimer <= uiDiff)
@@ -278,7 +295,6 @@ struct npc_emilyAI : public npc_escortAI
}
};
bool QuestAccept_npc_emily(Player* pPlayer, Creature* pCreature, Quest const* quest)
{
if (quest->GetQuestId() == QUEST_PERILOUS_ADVENTURE)
@@ -305,23 +321,13 @@ CreatureAI* GetAI_npc_emily(Creature* pCreature)
struct npc_mrfloppyAI : public ScriptedAI
{
npc_mrfloppyAI(Creature *c) : ScriptedAI(c) {}
uint64 EmilyGUID;
uint64 RWORGGUID;
uint64 HWORGGUID;
Creature* HWORG;
Creature* RWORG;
Creature* Emily;
void Reset()
{
HWORG = NULL;
RWORG = NULL;
Emily = NULL;
}
void Reset() {}
void EnterCombat(Unit* Who)
{
if (Creature* Emily = GetClosestCreatureWithEntry(m_creature, NPC_EMILY, 50.0f))
@@ -339,11 +345,11 @@ struct npc_mrfloppyAI : public ScriptedAI
}
}
}
void EnterEvadeMode() {}
void MoveInLineOfSight(Unit *who) {}
void UpdateAI(const uint32 diff)
{
if (!UpdateVictim())
@@ -281,7 +281,7 @@ struct boss_kelthuzadAI : public BossAI
me->setFaction(35);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_NOT_SELECTABLE);
std::map<uint64, float>::iterator itr;
std::map<uint64, float>::const_iterator itr;
for (itr = chained.begin(); itr != chained.end(); ++itr)
{
if (Player* charmed = Unit::GetPlayer((*itr).first))
@@ -326,7 +326,7 @@ struct boss_kelthuzadAI : public BossAI
_JustDied();
DoScriptText(SAY_DEATH, m_creature);
std::map<uint64, float>::iterator itr;
std::map<uint64, float>::const_iterator itr;
for (itr = chained.begin(); itr != chained.end(); ++itr)
{
if (Player* pPlayer = Unit::GetPlayer((*itr).first))
@@ -573,7 +573,7 @@ struct boss_kelthuzadAI : public BossAI
}
}
}
itr++;
++itr;
}
if (chained.empty())
@@ -597,7 +597,7 @@ struct boss_kelthuzadAI : public BossAI
if (!unitList.empty())
{
std::vector<Unit*>::iterator itr = unitList.begin();
std::vector<Unit*>::const_iterator itr = unitList.begin();
advance(itr, rand()%unitList.size());
DoCast(*itr, SPELL_MANA_DETONATION);
DoScriptText(RAND(SAY_SPECIAL_1,SAY_SPECIAL_2,SAY_SPECIAL_3), me);
@@ -111,7 +111,7 @@ struct boss_patchwerkAI : public BossAI
//amount of HP within melee distance
uint32 MostHP = 0;
Unit* pMostHPTarget = NULL;
std::list<HostileReference*>::iterator i = me->getThreatManager().getThreatList().begin();
std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin();
for (; i != me->getThreatManager().getThreatList().end(); ++i)
{
Unit *pTarget = (*i)->getTarget();
@@ -202,7 +202,7 @@ struct boss_sapphironAI : public BossAI
void ClearIceBlock()
{
for (IceBlockMap::iterator itr = iceblocks.begin(); itr != iceblocks.end(); ++itr)
for (IceBlockMap::const_iterator itr = iceblocks.begin(); itr != iceblocks.end(); ++itr)
{
if (Player* pPlayer = Unit::GetPlayer(itr->first))
pPlayer->RemoveAura(SPELL_ICEBOLT);
@@ -291,7 +291,7 @@ struct boss_sapphironAI : public BossAI
case EVENT_ICEBOLT:
{
std::vector<Unit*> targets;
std::list<HostileReference*>::iterator i = me->getThreatManager().getThreatList().begin();
std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin();
for (; i != me->getThreatManager().getThreatList().end(); ++i)
if ((*i)->getTarget()->GetTypeId() == TYPEID_PLAYER && !(*i)->getTarget()->HasAura(SPELL_ICEBOLT))
targets.push_back((*i)->getTarget());
@@ -300,7 +300,7 @@ struct boss_sapphironAI : public BossAI
iceboltCount = 0;
else
{
std::vector<Unit*>::iterator itr = targets.begin();
std::vector<Unit*>::const_iterator itr = targets.begin();
advance(itr, rand()%targets.size());
iceblocks.insert(std::make_pair((*itr)->GetGUID(), 0));
DoCast(*itr, SPELL_ICEBOLT);
@@ -348,7 +348,7 @@ struct boss_sapphironAI : public BossAI
{
DoZoneInCombat(); // make sure everyone is in threatlist
std::vector<Unit*> targets;
std::list<HostileReference*>::iterator i = me->getThreatManager().getThreatList().begin();
std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin();
for (; i != me->getThreatManager().getThreatList().end(); ++i)
{
Unit *pTarget = (*i)->getTarget();
@@ -362,7 +362,7 @@ struct boss_sapphironAI : public BossAI
continue;
}
for (IceBlockMap::iterator itr = iceblocks.begin(); itr != iceblocks.end(); ++itr)
for (IceBlockMap::const_iterator itr = iceblocks.begin(); itr != iceblocks.end(); ++itr)
{
if (GameObject* pGo = GameObject::GetGameObject(*me, itr->second))
{
@@ -379,7 +379,7 @@ struct boss_sapphironAI : public BossAI
me->CastSpell(me, SPELL_FROST_EXPLOSION, true);
for (std::vector<Unit*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
for (std::vector<Unit*>::const_iterator itr = targets.begin(); itr != targets.end(); ++itr)
(*itr)->ApplySpellImmune(0, IMMUNITY_ID, SPELL_FROST_EXPLOSION, false);
}
};
@@ -161,7 +161,7 @@ struct boss_keristraszaAI : public ScriptedAI
if (uiCheckIntenseColdTimer < diff && !bMoreThanTwoIntenseCold)
{
std::list<HostileReference*> ThreatList = m_creature->getThreatManager().getThreatList();
for (std::list<HostileReference*>::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); itr++)
for (std::list<HostileReference*>::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr)
{
Unit *pTarget = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
if (!pTarget || pTarget->GetTypeId() != TYPEID_PLAYER)
@@ -179,7 +179,7 @@ struct boss_ormorokAI : public ScriptedAI
case 3: Healer = CLASS_DRUID; break;
case 4: Healer = CLASS_SHAMAN; break;
}
std::list<HostileReference*>::iterator i = m_creature->getThreatManager().getThreatList().begin();
std::list<HostileReference*>::const_iterator i = m_creature->getThreatManager().getThreatList().begin();
for (; i != m_creature->getThreatManager().getThreatList().end(); ++i)
{
Unit* pTemp = Unit::GetUnit((*m_creature),(*i)->getUnitGuid());
@@ -152,7 +152,7 @@ struct boss_ionarAI : public ScriptedAI
if (m_lSparkGUIDList.empty())
return;
for (std::list<uint64>::iterator itr = m_lSparkGUIDList.begin(); itr != m_lSparkGUIDList.end(); ++itr)
for (std::list<uint64>::const_iterator itr = m_lSparkGUIDList.begin(); itr != m_lSparkGUIDList.end(); ++itr)
{
if (Creature* pTemp = m_creature->GetMap()->GetCreature(*itr))
{
@@ -173,7 +173,7 @@ struct boss_ionarAI : public ScriptedAI
Position pos;
m_creature->GetPosition(&pos);
for (std::list<uint64>::iterator itr = m_lSparkGUIDList.begin(); itr != m_lSparkGUIDList.end(); ++itr)
for (std::list<uint64>::const_iterator itr = m_lSparkGUIDList.begin(); itr != m_lSparkGUIDList.end(); ++itr)
{
if (Creature* pSpark = Unit::GetCreature(*m_creature, *itr))
{
@@ -169,7 +169,7 @@ struct boss_volkhanAI : public ScriptedAI
if (m_lGolemGUIDList.empty())
return;
for (std::list<uint64>::iterator itr = m_lGolemGUIDList.begin(); itr != m_lGolemGUIDList.end(); ++itr)
for (std::list<uint64>::const_iterator itr = m_lGolemGUIDList.begin(); itr != m_lGolemGUIDList.end(); ++itr)
{
if (Creature* pTemp = Unit::GetCreature(*m_creature, *itr))
{
@@ -186,7 +186,7 @@ struct boss_volkhanAI : public ScriptedAI
if (m_lGolemGUIDList.empty())
return;
for (std::list<uint64>::iterator itr = m_lGolemGUIDList.begin(); itr != m_lGolemGUIDList.end(); ++itr)
for (std::list<uint64>::const_iterator itr = m_lGolemGUIDList.begin(); itr != m_lGolemGUIDList.end(); ++itr)
{
if (Creature* pTemp = Unit::GetCreature(*m_creature, *itr))
{
@@ -162,7 +162,7 @@ struct mob_tribuna_controllerAI : public ScriptedAI
if (!lKaddrakGUIDList.empty())
{
uint32 uiPositionCounter = 0;
for (std::list<Creature*>::iterator itr = lKaddrakGUIDList.begin(); itr != lKaddrakGUIDList.end(); ++itr)
for (std::list<Creature*>::const_iterator itr = lKaddrakGUIDList.begin(); itr != lKaddrakGUIDList.end(); ++itr)
{
if ((*itr)->isAlive())
{
@@ -277,7 +277,7 @@ struct npc_brann_hosAI : public npc_escortAI
{
if (lDwarfGUIDList.empty())
return;
for (std::list<uint64>::iterator itr = lDwarfGUIDList.begin(); itr != lDwarfGUIDList.end(); ++itr)
for (std::list<uint64>::const_iterator itr = lDwarfGUIDList.begin(); itr != lDwarfGUIDList.end(); ++itr)
{
Creature* pTemp = Unit::GetCreature(*m_creature, pInstance ? (*itr) : 0);
if (pTemp && pTemp->isAlive())
@@ -166,7 +166,7 @@ struct boss_algalonAI : public ScriptedAI
if (m_lCollapsingStarGUIDList.empty())
return;
for(std::list<uint64>::iterator itr = m_lCollapsingStarGUIDList.begin(); itr != m_lCollapsingStarGUIDList.end(); ++itr)
for(std::list<uint64>::const_iterator itr = m_lCollapsingStarGUIDList.begin(); itr != m_lCollapsingStarGUIDList.end(); ++itr)
{
if (Creature* pTemp = Unit::GetCreature(*m_creature, *itr))
{
@@ -187,7 +187,7 @@ struct boss_razorscaleAI : public BossAI
std::list<Unit*> pTargets;
SelectTargetList(pTargets, RAID_MODE(3,9), SELECT_TARGET_RANDOM, 100, true);
uint8 i = 0;
for (std::list<Unit*>::iterator itr = pTargets.begin(); itr != pTargets.end();)
for (std::list<Unit*>::const_iterator itr = pTargets.begin(); itr != pTargets.end();)
{
if (m_creature->HasInArc(M_PI, *itr))
{
@@ -236,7 +236,7 @@ struct boss_ichoronAI : public ScriptedAI
bool bIsWaterElementsAlive = false;
if (!m_waterElements.empty())
{
for (std::list<uint64>::iterator itr = m_waterElements.begin(); itr != m_waterElements.end(); ++itr)
for (std::list<uint64>::const_iterator itr = m_waterElements.begin(); itr != m_waterElements.end(); ++itr)
if (Creature* pTemp = Unit::GetCreature(*m_creature, *itr))
if (pTemp->isAlive())
{
@@ -100,7 +100,7 @@ struct boss_xevozzAI : public ScriptedAI
if (assistList.empty())
return;
for(std::list<Creature*>::iterator iter = assistList.begin(); iter != assistList.end(); ++iter)
for(std::list<Creature*>::const_iterator iter = assistList.begin(); iter != assistList.end(); ++iter)
{
if (Creature* pSphere = *iter)
pSphere->Kill(pSphere, false);
@@ -105,7 +105,7 @@ struct npc_sinclariAI : public ScriptedAI
std::list<Creature*> GuardList;
m_creature->GetCreatureListWithEntryInGrid(GuardList, NPC_VIOLET_HOLD_GUARD, 40.0f);
if (!GuardList.empty())
for (std::list<Creature*>::iterator itr = GuardList.begin(); itr != GuardList.end(); ++itr)
for (std::list<Creature*>::const_iterator itr = GuardList.begin(); itr != GuardList.end(); ++itr)
{
if (Creature* pGuard = *itr)
{
@@ -122,7 +122,7 @@ struct npc_sinclariAI : public ScriptedAI
std::list<Creature*> GuardList;
m_creature->GetCreatureListWithEntryInGrid(GuardList, NPC_VIOLET_HOLD_GUARD, 40.0f);
if (!GuardList.empty())
for (std::list<Creature*>::iterator itr = GuardList.begin(); itr != GuardList.end(); ++itr)
for (std::list<Creature*>::const_iterator itr = GuardList.begin(); itr != GuardList.end(); ++itr)
{
if (Creature* pGuard = *itr)
{
+28 -16
View File
@@ -37,11 +37,11 @@ struct npc_drakuru_shacklesAI : public ScriptedAI
{
npc_drakuru_shacklesAI(Creature* pCreature) : ScriptedAI(pCreature) {}
Unit* Rageclaw;
uint64 RageclawGUID;
void Reset()
{
Rageclaw = NULL;
RageclawGUID = 0;
m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
float x, y, z;
@@ -50,13 +50,15 @@ struct npc_drakuru_shacklesAI : public ScriptedAI
if (Unit* summon = m_creature->SummonCreature(NPC_RAGECLAW, x, y, z,
0, TEMPSUMMON_DEAD_DESPAWN, 1000))
{
Rageclaw = summon;
RageclawGUID = summon->GetGUID();
LockRageclaw();
}
}
void LockRageclaw()
{
Unit *Rageclaw = Unit::GetCreature(*m_creature, RageclawGUID);
// pointer check not needed
m_creature->SetInFront(Rageclaw);
Rageclaw->SetInFront(m_creature);
@@ -69,6 +71,8 @@ struct npc_drakuru_shacklesAI : public ScriptedAI
if (!pWho)
return;
Creature *Rageclaw = Unit::GetCreature(*m_creature, RageclawGUID);
// pointer check not needed
DoCast(Rageclaw, SPELL_FREE_RAGECLAW, true);
m_creature->setDeathState(DEAD);
@@ -78,7 +82,7 @@ struct npc_drakuru_shacklesAI : public ScriptedAI
{
if (pSpell->Id == SPELL_UNLOCK_SHACKLE)
{
if (Rageclaw)
if (Creature *Rageclaw = Unit::GetCreature(*m_creature, RageclawGUID))
UnlockRageclaw(pCaster);
else
m_creature->setDeathState(JUST_DIED);
@@ -240,10 +244,9 @@ struct npc_gurgthockAI : public ScriptedAI
{
npc_gurgthockAI(Creature* pCreature) : ScriptedAI(pCreature)
{
pSummon = NULL;
}
Unit* pSummon;
uint64 SummonGUID;
std::list<uint64> SummonList;
@@ -257,6 +260,7 @@ struct npc_gurgthockAI : public ScriptedAI
void Reset()
{
SummonGUID = 0;
m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
uiTimer = 0;
uiPhase = 0;
@@ -275,7 +279,7 @@ struct npc_gurgthockAI : public ScriptedAI
m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
for(std::list<uint64>::iterator itr = SummonList.begin(); itr != SummonList.end(); ++itr)
for(std::list<uint64>::const_iterator itr = SummonList.begin(); itr != SummonList.end(); ++itr)
{
if (Creature* pTemp = Unit::GetCreature(*m_creature, *itr))
if (pTemp)
@@ -344,15 +348,16 @@ struct npc_gurgthockAI : public ScriptedAI
switch(uiPhase)
{
case 1:
pSummon = m_creature->SummonCreature(NPC_ORINOKO_TUSKBREAKER, SpawnPosition[0], TEMPSUMMON_CORPSE_DESPAWN, 1000);
if (Creature *pSummon = m_creature->SummonCreature(NPC_ORINOKO_TUSKBREAKER, SpawnPosition[0], TEMPSUMMON_CORPSE_DESPAWN, 1000))
SummonGUID = pSummon->GetGUID();
uiPhase = 2;
uiTimer = 4000;
break;
case 2:
if (pSummon)
if (Creature *pSummon = Unit::GetCreature(*m_creature, SummonGUID))
pSummon->GetMotionMaster()->MoveJump(5776.319824, -2981.005371, 273.100037, 10.0f, 20.0f);
uiPhase = 0;
pSummon = NULL;
SummonGUID = 0;
break;
case 3:
DoScriptText(SAY_QUEST_ACCEPT_KORRAK_2, m_creature);
@@ -360,7 +365,8 @@ struct npc_gurgthockAI : public ScriptedAI
uiPhase = 4;
break;
case 4:
pSummon = m_creature->SummonCreature(NPC_KORRAK_BLOODRAGER, SpawnPosition[0], TEMPSUMMON_CORPSE_DESPAWN, 1000);
if (Creature *pSummon = m_creature->SummonCreature(NPC_KORRAK_BLOODRAGER, SpawnPosition[0], TEMPSUMMON_CORPSE_DESPAWN, 1000))
SummonGUID = pSummon->GetGUID();
uiTimer = 3000;
uiPhase = 0;
break;
@@ -454,7 +460,7 @@ struct npc_orinoko_tuskbreakerAI : public ScriptedAI
uint32 uiBattleShoutTimer;
uint32 uiFishyScentTimer;
Unit* pAffected;
uint64 AffectedGUID;
uint64 uiWhisker;
void Reset()
@@ -465,7 +471,7 @@ struct npc_orinoko_tuskbreakerAI : public ScriptedAI
uiBattleShoutTimer = 0;
uiFishyScentTimer = 20000;
uiWhisker = 0;
pAffected = NULL;
AffectedGUID = 0;
}
void EnterEvadeMode()
@@ -509,8 +515,11 @@ struct npc_orinoko_tuskbreakerAI : public ScriptedAI
if (uiFishyScentTimer <= uiDiff)
{
if (pAffected = SelectUnit(SELECT_TARGET_RANDOM,0))
if (Unit *pAffected = SelectUnit(SELECT_TARGET_RANDOM,0))
{
DoCast(pAffected, SPELL_FISHY_SCENT);
AffectedGUID = pAffected->GetGUID();
}
uiFishyScentTimer = 20000;
} else uiFishyScentTimer -= uiDiff;
@@ -535,8 +544,11 @@ struct npc_orinoko_tuskbreakerAI : public ScriptedAI
pSummon->AI()->AttackStart(m_creature->getVictim());
break;
case NPC_HUNGRY_PENGUIN:
if (pAffected && pAffected->isAlive())
pSummon->AI()->AttackStart(pAffected);
if(Unit *pAffected = Unit::GetUnit(*m_creature, AffectedGUID))
{
if (pAffected->isAlive())
pSummon->AI()->AttackStart(pAffected);
}
break;
}
}