本文整理汇总了C++中map::playerlist::const_iterator类的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator类的具体用法?C++ const_iterator怎么用?C++ const_iterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了const_iterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateAI
void UpdateAI(const uint32 diff)
{
npc_escortAI::UpdateAI(diff);
if(!UpdateVictim())
return;
if(uiBuffTimer <= diff)
{
if(!me->HasAura(SPELL_SHIELD))
DoCastSpellShield();
uiBuffTimer = urand(30000, 45000);
} else uiBuffTimer -= diff;
if(uiChargeTimer <= diff)
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if(me->GetMap()->IsDungeon() && !players.isEmpty())
{
for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
Player* pPlayer = itr->getSource();
if(pPlayer && me->IsInRange(pPlayer, 8.0f, 25.0f,false) && pPlayer->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT))
{
Creature* pVehicle = pPlayer->GetVehicleBase()->ToCreature();
if(pVehicle)
{
DoResetThreat();
me->AddThreat(pVehicle, 1.0f);
DoCast(pVehicle, SPELL_CHARGE);
}
break;
}
}
}
uiChargeTimer = 5000;
} else uiChargeTimer -= diff;
/*if(uiShieldBreakerTimer <= diff)
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if(me->GetMap()->IsDungeon() && !players.isEmpty())
{
for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
Player* pPlayer = itr->getSource();
if(pPlayer && me->IsInRange(pPlayer, 10.0f, 30.0f,false) && pPlayer->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT))
{
Creature* pVehicle = pPlayer->GetVehicleBase()->ToCreature();
if(pVehicle)
{
DoResetThreat();
me->AddThreat(pVehicle, 1.0f);
//DoCast(pVehicle,SPELL_SHIELD_BREAKER);
if(Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 30.0f, true))
me->CastSpell(target, SPELL_SHIELD_BREAKER, true);
}
break;
}
}
}
uiShieldBreakerTimer = 7000;
} else uiShieldBreakerTimer -= diff;
*/
if(uiShieldBreakerTimer <= diff)
{
if(Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true))
{
switch(urand(1, 3)) {
case 1:
case 2:
break;
case 3:
me->CastSpell(target, SPELL_SHIELD_BREAKER, true);
break;
}
}
uiShieldBreakerTimer = 7000;
} else uiShieldBreakerTimer -= diff;
/*
if(uiChargeTimer <= diff)
{
if(Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true))
me->CastSpell(target, SPELL_CHARGE, true);
uiChargeTimer = 3000;
} else uiChargeTimer -= diff;
*/
DoMeleeAttackIfReady();
}
示例2: UpdateAI
void UpdateAI(const uint32 uiDiff)
{
npc_escortAI::UpdateAI(uiDiff);
if (!UpdateVictim())
return;
if (uiBuffTimer <= uiDiff)
{
if (!me->HasAura(SPELL_SHIELD))
DoCastSpellShield();
uiBuffTimer = urand(30000, 45000);
}else uiBuffTimer -= uiDiff;
if (uiChargeTimer <= uiDiff)
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if (me->GetMap()->IsDungeon() && !players.isEmpty())
{
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
Player* player = itr->getSource();
if (player && !player->isGameMaster() && me->IsInRange(player, 8.0f, 25.0f, false))
{
DoResetThreat();
me->AddThreat(player, 1.0f);
DoCast(player, SPELL_CHARGE);
break;
}
}
}
uiChargeTimer = 5000;
}else uiChargeTimer -= uiDiff;
//dosen't work at all
if (uiShieldBreakerTimer <= uiDiff)
{
Vehicle* pVehicle = me->GetVehicleKit();
if (!pVehicle)
return;
if (Unit* pPassenger = pVehicle->GetPassenger(SEAT_ID_0))
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if (me->GetMap()->IsDungeon() && !players.isEmpty())
{
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
Player* player = itr->getSource();
if (player && !player->isGameMaster() && me->IsInRange(player, 10.0f, 30.0f, false))
{
pPassenger->CastSpell(player, SPELL_SHIELD_BREAKER, true);
break;
}
}
}
}
uiShieldBreakerTimer = 7000;
}else uiShieldBreakerTimer -= uiDiff;
DoMeleeAttackIfReady();
}
示例3: SetData
void SetData(uint32 type, uint32 data)
{
switch (type)
{
case TYPE_MEDIVH:
if (data == SPECIAL && m_auiEncounter[0] == IN_PROGRESS)
{
--mShieldPercent;
DoUpdateWorldState(WORLD_STATE_BM_SHIELD, mShieldPercent);
if (!mShieldPercent)
{
if (Creature* pMedivh = instance->GetCreature(MedivhGUID))
{
if (pMedivh->isAlive())
{
pMedivh->DealDamage(pMedivh, pMedivh->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
m_auiEncounter[0] = FAIL;
m_auiEncounter[1] = NOT_STARTED;
}
}
}
}
else
{
if (data == IN_PROGRESS)
{
sLog->outDebug(LOG_FILTER_TSCR, "TSCR: Instance Dark Portal: Starting event.");
InitWorldState();
m_auiEncounter[1] = IN_PROGRESS;
NextPortal_Timer = 15000;
}
if (data == DONE)
{
//this may be completed further out in the post-event
sLog->outDebug(LOG_FILTER_TSCR, "TSCR: Instance Dark Portal: Event completed.");
Map::PlayerList const& players = instance->GetPlayers();
if (!players.isEmpty())
{
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* player = itr->getSource())
{
if (player->GetQuestStatus(QUEST_OPENING_PORTAL) == QUEST_STATUS_INCOMPLETE)
player->AreaExploredOrEventHappens(QUEST_OPENING_PORTAL);
if (player->GetQuestStatus(QUEST_MASTER_TOUCH) == QUEST_STATUS_INCOMPLETE)
player->AreaExploredOrEventHappens(QUEST_MASTER_TOUCH);
}
}
}
}
m_auiEncounter[0] = data;
}
break;
case TYPE_RIFT:
if (data == SPECIAL)
{
if (mRiftPortalCount < 7)
NextPortal_Timer = 5000;
}
else
m_auiEncounter[1] = data;
break;
}
}
示例4: SetData
void instance_dire_maul::SetData(uint32 uiType, uint32 uiData)
{
switch (uiType)
{
// East
case TYPE_ZEVRIM:
if (uiData == DONE)
{
// Update Old Ironbark so he can open the conservatory door
if (Creature* pIronbark = GetSingleCreatureFromStorage(NPC_OLD_IRONBARK))
{
DoScriptText(SAY_IRONBARK_REDEEM, pIronbark);
pIronbark->UpdateEntry(NPC_IRONBARK_REDEEMED);
}
}
m_auiEncounter[uiType] = uiData;
break;
case TYPE_IRONBARK:
m_auiEncounter[uiType] = uiData;
break;
case TYPE_ALZZIN: // This Encounter is expected to be handled within Acid (reason handling at 50% hp)
if (uiData == DONE)
{
if (!m_bWallDestroyed)
{
DoUseDoorOrButton(GO_CRUMBLE_WALL);
m_bWallDestroyed = true;
}
DoUseDoorOrButton(GO_CORRUPT_VINE);
if (!m_lFelvineShardGUIDs.empty())
{
for (GuidList::const_iterator itr = m_lFelvineShardGUIDs.begin(); itr != m_lFelvineShardGUIDs.end(); ++itr)
DoRespawnGameObject(*itr);
}
}
else if (uiData == SPECIAL && !m_bWallDestroyed)
{
DoUseDoorOrButton(GO_CRUMBLE_WALL);
m_bWallDestroyed = true;
}
m_auiEncounter[uiType] = uiData;
break;
// West
case TYPE_WARPWOOD:
if (uiData == DONE)
DoUseDoorOrButton(GO_WARPWOOD_DOOR);
m_auiEncounter[uiType] = uiData;
break;
case TYPE_IMMOLTHAR:
if (uiData == DONE)
{
if (Creature* pPrince = GetSingleCreatureFromStorage(NPC_PRINCE_TORTHELDRIN))
{
DoScriptText(SAY_FREE_IMMOLTHAR, pPrince);
pPrince->setFaction(FACTION_HOSTILE);
// Despawn Chest-Aura
if (GameObject* pChestAura = GetSingleGameObjectFromStorage(GO_PRINCES_CHEST_AURA))
pChestAura->Use(pPrince);
}
}
m_auiEncounter[uiType] = uiData;
break;
case TYPE_PRINCE:
m_auiEncounter[uiType] = uiData;
break;
case TYPE_PYLON_1:
case TYPE_PYLON_2:
case TYPE_PYLON_3:
case TYPE_PYLON_4:
case TYPE_PYLON_5:
m_auiEncounter[uiType] = uiData;
if (uiData == DONE)
{
DoUseDoorOrButton(m_aCrystalGeneratorGuid[uiType - TYPE_PYLON_1]);
if (CheckAllGeneratorsDestroyed())
ProcessForceFieldOpening();
}
break;
// North
case TYPE_KING_GORDOK:
m_auiEncounter[uiType] = uiData;
if (uiData == DONE)
{
// Apply Aura to players in the map
Map::PlayerList const& players = instance->GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* pPlayer = itr->getSource())
pPlayer->CastSpell(pPlayer, SPELL_KING_OF_GORDOK, true);
}
}
break;
}
if (uiData == DONE)
{
//.........这里部分代码省略.........
示例5: SetBossState
//.........这里部分代码省略.........
break;
}
case DONE:
{
HandleGameObject(cloudstikeEntranceGuid, true);
HandleGameObject(cloudstikeExitGuid, true);
HandleGameObject(snowdriftEntranceGuid, true);
break;
}
default:
break;
}
break;
}
case DATA_MASTER_SNOWDRIFT:
{
switch (state)
{
case NOT_STARTED:
case FAIL:
aliveNoviceCount = MAX_NOVICE;
aliveMinibossCount = 2;
minibossPositionsGuid.clear();
firstDefeatedNovicePositionsGuid.clear();
secondDefeatedNovicePositionsGuid.clear();
HandleGameObject(snowdriftEntranceGuid, true);
HandleGameObject(snowdriftFirewallGuid, false);
HandleGameObject(snowdriftDojoDoorGuid, false);
HandleGameObject(snowdriftExitGuid, false);
break;
case IN_PROGRESS:
HandleGameObject(snowdriftEntranceGuid, false);
HandleGameObject(snowdriftDojoDoorGuid, false);
break;
case DONE:
if (GameObject* possessions = instance->GetGameObject(snowdriftPossessionsGuid))
possessions->SetPhaseMask(1, true);
HandleGameObject(snowdriftEntranceGuid, true);
HandleGameObject(snowdriftFirewallGuid, true);
HandleGameObject(snowdriftDojoDoorGuid, true);
HandleGameObject(snowdriftExitGuid, true);
HandleGameObject(shaEntranceGuid, true);
break;
default:
break;
}
break;
}
case DATA_SHA_VIOLENCE:
{
switch (state)
{
case NOT_STARTED:
case FAIL:
HandleGameObject(shaEntranceGuid, true);
HandleGameObject(shaExitGuid, false);
break;
case IN_PROGRESS:
HandleGameObject(shaEntranceGuid, false);
break;
case DONE:
HandleGameObject(shaEntranceGuid, true);
HandleGameObject(shaExitGuid, true);
break;
default:
break;
}
break;
}
case DATA_TARAN_ZHU:
{
if (state == IN_PROGRESS)
DoAddAuraOnPlayers(SPELL_HATE);
else
{
Map::PlayerList const &PlayerList = instance->GetPlayers();
if (!PlayerList.isEmpty())
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
if (Player* player = i->GetSource())
{
player->RemoveAurasDueToSpell(SPELL_HATE);
player->RemoveAurasDueToSpell(SPELL_HAZE_OF_HATE);
player->RemoveAurasDueToSpell(SPELL_HAZE_OF_HATE_VISUAL);
}
}
if (state == DONE)
if (GameObject* possessions = instance->GetGameObject(taranzhuPossessionsGuid))
possessions->SetPhaseMask(1, true);
break;
}
default:
break;
}
return true;
}
示例6: UpdateAI
void UpdateAI(const uint32 diff)
{
if (!UpdateVictim())
return;
if (ResetTimer <= diff)
{
if (me->IsWithinDist3d(119.223f, 1035.45f, 29.4481f, 10))
{
EnterEvadeMode();
return;
}
ResetTimer = 5000;
} else ResetTimer -= diff;
if (CheckAddState_Timer <= diff)
{
for (uint8 i = 0; i < 4; ++i)
if (Creature *pTemp = Unit::GetCreature(*me, AddGUID[i]))
if (pTemp->isAlive() && !pTemp->getVictim())
pTemp->AI()->AttackStart(me->getVictim());
CheckAddState_Timer = 5000;
} else CheckAddState_Timer -= diff;
if (DrainPower_Timer <= diff)
{
DoCast(me, SPELL_DRAIN_POWER, true);
Map *map = me->GetMap();
if (!map->IsDungeon()) return;
Map::PlayerList const &PlayerList = map->GetPlayers();
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
if (Player* i_pl = i->getSource())
if (i_pl->isAlive())me->AddAura(44132, me); //+1% Damage for each active player on boss (+ActivePlayer_Stack)
}
//me->AddAura(44132, me);
me->MonsterYell(YELL_DRAIN_POWER, LANG_UNIVERSAL, NULL);
DoPlaySoundToSet(me, SOUND_YELL_DRAIN_POWER);
DrainPower_Timer = urand(40000,55000); // must cast in 60 sec, or buff/debuff will disappear
} else DrainPower_Timer -= diff;
if (SpiritBolts_Timer <= diff)
{
if (DrainPower_Timer < 12000) // channel 10 sec
SpiritBolts_Timer = 13000; // cast drain power first
else
{
DoCast(me, SPELL_SPIRIT_BOLTS, true);
me->MonsterYell(YELL_SPIRIT_BOLTS, LANG_UNIVERSAL, NULL);
DoPlaySoundToSet(me, SOUND_YELL_SPIRIT_BOLTS);
SpiritBolts_Timer = 40000;
SiphonSoul_Timer = 10000; // ready to drain
PlayerAbility_Timer = 99999;
}
} else SpiritBolts_Timer -= diff;
if (SiphonSoul_Timer <= diff)
{
Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 70, true);
Unit *trigger = DoSpawnCreature(MOB_TEMP_TRIGGER, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 30000);
if (!pTarget || !trigger)
{
EnterEvadeMode();
return;
}
else
{
trigger->SetDisplayId(11686);
trigger->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
trigger->CastSpell(pTarget, SPELL_SIPHON_SOUL, true);
trigger->GetMotionMaster()->MoveChase(me);
//DoCast(pTarget, SPELL_SIPHON_SOUL, true);
//me->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, pTarget->GetGUID());
//me->SetUInt32Value(UNIT_CHANNEL_SPELL, SPELL_SIPHON_SOUL);
PlayerGUID = pTarget->GetGUID();
PlayerAbility_Timer = urand(8000,10000);
PlayerClass = pTarget->getClass() - 1;
if (PlayerClass == 10)
PlayerClass = 9; // druid
else if (PlayerClass == 4 && pTarget->HasSpell(15473))
PlayerClass = 5; // shadow priest
SiphonSoul_Timer = 99999; // buff lasts 30 sec
}
} else SiphonSoul_Timer -= diff;
if (PlayerAbility_Timer <= diff)
{
//Unit *pTarget = Unit::GetUnit(*me, PlayerGUID);
//if (pTarget && pTarget->isAlive())
//{
UseAbility();
PlayerAbility_Timer = urand(8000,10000);
//}
} else PlayerAbility_Timer -= diff;
//.........这里部分代码省略.........
示例7: DoZoneInCombat
void CreatureAI::DoZoneInCombat(Creature* creature)
{
if (!creature)
creature = me;
if(!creature->CanHaveThreatList())
return;
Map *map = creature->GetMap();
if (!map->IsDungeon()) //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated
{
sLog.outError("DoZoneInCombat call for map that isn't an instance (creature entry = %d)", creature->GetTypeId() == TYPEID_UNIT ? ((Creature*)creature)->GetEntry() : 0);
return;
}
if(!creature->HasReactState(REACT_PASSIVE) && !creature->getVictim())
{
if(Unit *target = creature->SelectNearestTarget(50))
creature->AI()->AttackStart(target);
else if(creature->isSummon())
{
if(Unit *summoner = ((TempSummon*)creature)->GetSummoner())
{
Unit *target = summoner->getAttackerForHelper();
if(!target && summoner->CanHaveThreatList() && !summoner->getThreatManager().isThreatListEmpty())
target = summoner->getThreatManager().getHostilTarget();
if(target && (creature->IsFriendlyTo(summoner) || creature->IsHostileTo(target)))
creature->AI()->AttackStart(target);
}
}
}
if(!creature->HasReactState(REACT_PASSIVE) && !creature->getVictim())
{
sLog.outError("DoZoneInCombat called for creature that has empty threat list (creature entry = %u)", creature->GetEntry());
return;
}
Map::PlayerList const &PlList = map->GetPlayers();
if(PlList.isEmpty())
return;
for(Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
{
if(Player* pPlayer = i->getSource())
{
if(pPlayer->isGameMaster())
continue;
if(pPlayer->isAlive())
{
creature->SetInCombatWith(pPlayer);
pPlayer->SetInCombatWith(creature);
creature->AddThreat(pPlayer, 0.0f);
}
/* Causes certain things to never leave the threat list (Priest Lightwell, etc):
for(Unit::ControlList::const_iterator itr = pPlayer->m_Controlled.begin(); itr != pPlayer->m_Controlled.end(); ++itr)
{
creature->SetInCombatWith(*itr);
(*itr)->SetInCombatWith(creature);
creature->AddThreat(*itr, 0.0f);
}*/
}
}
}
示例8: UpdateAI
void UpdateAI(const uint32 diff)
{
if (isFlameBreathing)
{
if (!me->IsNonMeleeSpellCasted(false))
isFlameBreathing = false;
else
return;
}
if (isBombing)
{
if (BombSequenceTimer <= diff)
HandleBombSequence();
else
BombSequenceTimer -= diff;
return;
}
if (!UpdateVictim())
return;
//enrage if under 25% hp before 5 min.
if (!enraged && HealthBelowPct(25))
EnrageTimer = 0;
if (EnrageTimer <= diff)
{
if (!enraged)
{
DoCast(me, SPELL_ENRAGE, true);
enraged = true;
EnrageTimer = 300000;
}
else
{
DoScriptText(SAY_BERSERK, me);
DoCast(me, SPELL_BERSERK, true);
EnrageTimer = 300000;
}
} else EnrageTimer -= diff;
if (BombTimer <= diff)
{
DoScriptText(SAY_FIRE_BOMBS, me);
me->AttackStop();
me->GetMotionMaster()->Clear();
DoTeleportTo(JanalainPos[0][0],JanalainPos[0][1],JanalainPos[0][2]);
me->StopMoving();
DoCast(me, SPELL_FIRE_BOMB_CHANNEL, false);
//DoTeleportPlayer(me, JanalainPos[0][0], JanalainPos[0][1],JanalainPos[0][2], 0);
//DoCast(me, SPELL_TELE_TO_CENTER, true);
FireWall();
SpawnBombs();
isBombing = true;
BombSequenceTimer = 100;
//Teleport every Player into the middle
Map* pMap = me->GetMap();
if (!pMap->IsDungeon()) return;
Map::PlayerList const &PlayerList = pMap->GetPlayers();
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
if (Player* i_pl = i->getSource())
if (i_pl->isAlive())
DoTeleportPlayer(i_pl, JanalainPos[0][0]-5+rand()%10, JanalainPos[0][1]-5+rand()%10, JanalainPos[0][2], 0);
//DoCast(Temp, SPELL_SUMMON_PLAYERS, true) // core bug, spell does not work if too far
return;
} else BombTimer -= diff;
if (!noeggs)
{
if (HealthBelowPct(35))
{
DoScriptText(SAY_ALL_EGGS, me);
me->AttackStop();
me->GetMotionMaster()->Clear();
DoTeleportTo(JanalainPos[0][0],JanalainPos[0][1],JanalainPos[0][2]);
me->StopMoving();
DoCast(me, SPELL_HATCH_ALL, false);
HatchAllEggs(2);
noeggs = true;
}
else if (HatcherTimer <= diff)
{
if (HatchAllEggs(0))
{
DoScriptText(SAY_SUMMON_HATCHER, me);
me->SummonCreature(MOB_AMANI_HATCHER,hatcherway[0][0][0],hatcherway[0][0][1],hatcherway[0][0][2],0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,10000);
me->SummonCreature(MOB_AMANI_HATCHER,hatcherway[1][0][0],hatcherway[1][0][1],hatcherway[1][0][2],0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,10000);
HatcherTimer = 90000;
}
else
noeggs = true;
} else HatcherTimer -= diff;
}
EnterEvadeIfOutOfCombatArea(diff);
//.........这里部分代码省略.........
示例9: Update
void Update (uint32 diff)
{
//Lurker Fishing event
if (LurkerSubEvent == LURKER_FISHING)
{
if (FishingTimer < diff)
{
LurkerSubEvent = LURKER_HOOKED;
SetData(DATA_STRANGE_POOL, IN_PROGRESS);//just fished, signal Lurker script to emerge and start fight, we use IN_PROGRESS so it won't get saved and lurker will be alway invis at start if server restarted
}
else
FishingTimer -= diff;
}
if (trashCheckTimer < diff)
{
if (Encounters[2] == NOT_STARTED) // check and change water state only if lurker event is not started
{
uint64 tmpPriestessGuid = instance->GetCreatureGUID(TRASHMOB_COILFANG_PRIESTESS, GET_ALIVE_CREATURE_GUID);
uint64 tmpShattererGuid = instance->GetCreatureGUID(TRASHMOB_COILFANG_SHATTERER, GET_ALIVE_CREATURE_GUID);
if (!tmpPriestessGuid && !tmpShattererGuid)
Water = WATERSTATE_SCALDING;
else
Water = WATERSTATE_FRENZY;
}
else if (Encounters[2] == DONE)
{
Water = WATERSTATE_NONE;
}
trashCheckTimer = 5000;
}
else
trashCheckTimer -= diff;
//Water checks
if (WaterCheckTimer < diff)
{
Map::PlayerList const &PlayerList = instance->GetPlayers();
if (PlayerList.isEmpty())
return;
bool PlayerInWater = false;
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
if(Player* pPlayer = i->getSource())
{
if (pPlayer->isAlive() && pPlayer->IsInWater())
{
PlayerInWater = true;
if (Water == WATERSTATE_SCALDING)
{
if (!pPlayer->HasAura(SPELL_SCALDINGWATER))
{
pPlayer->CastSpell(pPlayer, SPELL_SCALDINGWATER, true);
break;
}
}
else if (Water == WATERSTATE_FRENZY)
{
//spawn frenzy
if (DoSpawnFrenzy && !pPlayer->isGameMaster())
{
if (Creature* frenzy = pPlayer->SummonCreature(MOB_COILFANG_FRENZY,pPlayer->GetPositionX(),pPlayer->GetPositionY(),pPlayer->GetPositionZ(),pPlayer->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000))
{
frenzy->AddUnitMovementFlag(MOVEFLAG_SWIMMING);
frenzy->SetLevitate(true);
frenzy->AI()->AttackStart(pPlayer);
}
DoSpawnFrenzy = false;
}
}
else if (Water == WATERSTATE_NONE)
{
break;
}
}
}
}
if (PlayerInWater)
PlayerInWaterTimer = 5000;
else
{
if (PlayerInWaterTimer <= diff)
PlayerInWaterTimer = 0;
else
PlayerInWaterTimer -= diff;
}
if (PlayerInWaterTimer)
WaterCheckTimer = 1;
else
WaterCheckTimer = 500; //remove stress from core
}
else
WaterCheckTimer -= diff;
if (FrenzySpawnTimer < diff)
{
//.........这里部分代码省略.........
示例10: DoPrepareChessEvent
void instance_karazhan::DoPrepareChessEvent()
{
// Allow all the chess pieces to init start position
for (GuidList::const_iterator itr = m_lChessPiecesAlliance.begin(); itr != m_lChessPiecesAlliance.end(); ++itr)
{
if (Creature* pChessPiece = instance->GetCreature(*itr))
{
Creature* pSquare = GetClosestCreatureWithEntry(pChessPiece, NPC_SQUARE_BLACK, 2.0f);
if (!pSquare)
pSquare = GetClosestCreatureWithEntry(pChessPiece, NPC_SQUARE_WHITE, 2.0f);
if (!pSquare)
{
script_error_log("Instance Karazhan: ERROR Failed to properly load the Chess square for %s.", pChessPiece->GetGuidStr().c_str());
return;
}
// send event which will prepare the current square
pChessPiece->AI()->SendAIEvent(AI_EVENT_CUSTOM_B, pSquare, pChessPiece);
}
}
for (GuidList::const_iterator itr = m_lChessPiecesHorde.begin(); itr != m_lChessPiecesHorde.end(); ++itr)
{
if (Creature* pChessPiece = instance->GetCreature(*itr))
{
Creature* pSquare = GetClosestCreatureWithEntry(pChessPiece, NPC_SQUARE_BLACK, 2.0f);
if (!pSquare)
pSquare = GetClosestCreatureWithEntry(pChessPiece, NPC_SQUARE_WHITE, 2.0f);
if (!pSquare)
{
script_error_log("Instance Karazhan: ERROR Failed to properly load the Chess square for %s.", pChessPiece->GetGuidStr().c_str());
return;
}
// send event which will prepare the current square
pChessPiece->AI()->SendAIEvent(AI_EVENT_CUSTOM_B, pSquare, pChessPiece);
}
}
// add silence debuff
Map::PlayerList const& players = instance->GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* pPlayer = itr->getSource())
pPlayer->CastSpell(pPlayer, SPELL_GAME_IN_SESSION, true);
}
m_uiAllianceStalkerCount = 0;
m_uiHordeStalkerCount = 0;
m_vHordeStalkers.clear();
m_vAllianceStalkers.clear();
// sort stalkers depending on side
std::list<Creature*> lStalkers;
for (GuidList::const_iterator itr = m_lChessHordeStalkerList.begin(); itr != m_lChessHordeStalkerList.end(); ++itr)
{
if (Creature* pTemp = instance->GetCreature(*itr))
lStalkers.push_back(pTemp);
}
if (lStalkers.empty())
{
script_error_log("Instance Karazhan: ERROR Failed to properly load the horde side stalkers for the Chess Event.");
return;
}
// get the proper statusBar npc
Creature* pStatusBar = instance->GetCreature(m_HordeStatusGuid);
if (!pStatusBar)
return;
lStalkers.sort(ObjectDistanceOrder(pStatusBar));
for (std::list<Creature*>::const_iterator itr = lStalkers.begin(); itr != lStalkers.end(); ++itr)
m_vHordeStalkers.push_back((*itr)->GetObjectGuid());
lStalkers.clear();
for (GuidList::const_iterator itr = m_lChessAllianceStalkerList.begin(); itr != m_lChessAllianceStalkerList.end(); ++itr)
{
if (Creature* pTemp = instance->GetCreature(*itr))
lStalkers.push_back(pTemp);
}
if (lStalkers.empty())
{
script_error_log("Instance Karazhan: ERROR Failed to properly load the alliance side stalkers for the Chess Event.");
return;
}
// get the proper statusBar npc
pStatusBar = instance->GetCreature(m_AllianceStatusGuid);
if (!pStatusBar)
return;
lStalkers.sort(ObjectDistanceOrder(pStatusBar));
for (std::list<Creature*>::const_iterator itr = lStalkers.begin(); itr != lStalkers.end(); ++itr)
m_vAllianceStalkers.push_back((*itr)->GetObjectGuid());
}
示例11: JustDied
void JustDied(Unit* pKiller)
{
if (m_pInstance)
m_pInstance->SetData(TYPE_DEATHWHISPER, DONE);
DoScriptText(SAY_JUST_DIED_01, m_creature, pKiller);
// Achiev Full House Checks
bool bFullHouse = false;
uint8 cnt = 0;
std::list<Creature*> lCreatures;
lCreatures.clear();
GetCreatureListWithEntryInGrid(lCreatures, m_creature, NPC_FANATIC, 1000.0f);
if(CreatureInListIsAlive(lCreatures))
cnt++;
lCreatures.clear();
GetCreatureListWithEntryInGrid(lCreatures, m_creature, NPC_REANIMATED_FANATIC, 1000.0f);
if(CreatureInListIsAlive(lCreatures))
cnt++;
lCreatures.clear();
GetCreatureListWithEntryInGrid(lCreatures, m_creature, NPC_DEFORMED_FANATIC, 1000.0f);
if(CreatureInListIsAlive(lCreatures))
cnt++;
lCreatures.clear();
GetCreatureListWithEntryInGrid(lCreatures, m_creature, NPC_ADHERENT, 1000.0f);
if(CreatureInListIsAlive(lCreatures))
cnt++;
lCreatures.clear();
GetCreatureListWithEntryInGrid(lCreatures, m_creature, NPC_REANIMATED_ADHERENT, 1000.0f);
if(CreatureInListIsAlive(lCreatures))
cnt++;
lCreatures.clear();
GetCreatureListWithEntryInGrid(lCreatures, m_creature, NPC_EMPOWERED_ADHERENT, 1000.0f);
if(CreatureInListIsAlive(lCreatures))
cnt++;
if (cnt >= 5)
bFullHouse = true;
Map *pMap = m_creature->GetMap();
if(pMap && pMap->IsDungeon())
{
bool is25 = false;
switch (m_uiMode)
{
case RAID_DIFFICULTY_10MAN_NORMAL:
case RAID_DIFFICULTY_10MAN_HEROIC:
is25 = false;
break;
case RAID_DIFFICULTY_25MAN_NORMAL:
case RAID_DIFFICULTY_25MAN_HEROIC:
is25 = true;
break;
default:
break;
}
AchievementEntry const *AchievFullHouse = GetAchievementStore()->LookupEntry(is25 ? ACHIEV_FULL_HOUSE_25 : ACHIEV_FULL_HOUSE_10);
Map::PlayerList const &lPlayers = pMap->GetPlayers();
for (Map::PlayerList::const_iterator iter = lPlayers.begin(); iter != lPlayers.end(); ++iter)
{
iter->getSource()->RemoveAurasDueToSpell(SPELL_TOUCH_OF_INSIGNIFICANCE);
if (AchievFullHouse && bFullHouse)
{
iter->getSource()->CompletedAchievement(AchievFullHouse);
}
}
}
}
示例12: DoControlObsessedPlayers
void DoControlObsessedPlayers()
{
Map::PlayerList const &lPlayers = m_creature->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = lPlayers.begin(); itr != lPlayers.end(); ++itr)
{
if(Unit *pObsessed = ((Unit*)itr->getSource()))
{
if(pObsessed->HasAura(SPELL_DOMINATE_MIND))
{
if(!pObsessed->isAlive())
continue;
bool heal;
heal = roll_chance_i(20);
switch(pObsessed->getClass())
{
// classes witch healing spells
case CLASS_PRIEST:
if (heal)
{
pObsessed->CastSpell(m_creature, SPELL_FLASH_HEAL, false);
}
else
{
if(Unit* pTarget = SelectAttackingTargetForObsessed(pObsessed))
{
if (pObsessed->isAttackReady())
{
pObsessed->AttackerStateUpdate(pTarget);
pObsessed->resetAttackTimer();
}
else
pObsessed->GetMotionMaster()->MoveChase(pTarget, 1.0f);
}
}
break;
case CLASS_DRUID:
if (heal)
{
pObsessed->CastSpell(m_creature, SPELL_REJUVENATION, false);
}
else
{
if(Unit* pTarget = SelectAttackingTargetForObsessed(pObsessed))
{
if (pObsessed->isAttackReady())
{
pObsessed->AttackerStateUpdate(pTarget);
pObsessed->resetAttackTimer();
}
else
pObsessed->GetMotionMaster()->MoveChase(pTarget, 1.0f);
}
}
break;
case CLASS_PALADIN:
if (heal)
{
pObsessed->CastSpell(m_creature, SPELL_FLASH_OF_LIGHT, false);
}
else
{
if(Unit* pTarget = SelectAttackingTargetForObsessed(pObsessed))
{
if (pObsessed->isAttackReady())
{
pObsessed->AttackerStateUpdate(pTarget);
pObsessed->resetAttackTimer();
}
else
pObsessed->GetMotionMaster()->MoveChase(pTarget, 1.0f);
}
}
break;
case CLASS_SHAMAN:
if (heal)
{
pObsessed->CastSpell(m_creature, SPELL_CHAIN_HEAL, false);
}
else
{
if(Unit* pTarget = SelectAttackingTargetForObsessed(pObsessed))
{
if (pObsessed->isAttackReady())
{
pObsessed->AttackerStateUpdate(pTarget);
pObsessed->resetAttackTimer();
}
else
pObsessed->GetMotionMaster()->MoveChase(pTarget, 1.0f);
}
}
break;
case CLASS_MAGE:
if(Unit* pTarget = SelectAttackingTargetForObsessed(pObsessed))
{
pObsessed->CastSpell(pTarget, SPELL_ARCANE_MISSILES, false);
if (pObsessed->isAttackReady())
{
//.........这里部分代码省略.........
示例13: SetData
void SetData(uint32 type, uint32 data)
{
switch (type)
{
case DATA_RAGEWINTERCHILLEVENT:
m_auiEncounter[0] = data;
break;
case DATA_ANETHERONEVENT:
m_auiEncounter[1] = data;
break;
case DATA_KAZROGALEVENT:
m_auiEncounter[2] = data;
break;
case DATA_AZGALOREVENT:
{
m_auiEncounter[3] = data;
if (data == DONE)
{
if (ArchiYell)
break;
ArchiYell = true;
Creature* creature = instance->GetCreature(Azgalor);
if (creature)
{
Creature* unit = creature->SummonCreature(21987, creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000);
Map* map = creature->GetMap();
if (map->IsDungeon() && unit)
{
unit->SetVisible(false);
Map::PlayerList const &PlayerList = map->GetPlayers();
if (PlayerList.isEmpty())
return;
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
if (i->getSource())
{
WorldPacket packet(SMSG_MESSAGECHAT, 200);
unit->BuildMonsterChat(&packet, CHAT_MSG_MONSTER_YELL, YELL_EFFORTS, 0, YELL_EFFORTS_NAME, i->getSource()->GetGUID());
i->getSource()->GetSession()->SendPacket(&packet);
WorldPacket data2(SMSG_PLAY_SOUND, 4);
data2 << 10986;
i->getSource()->GetSession()->SendPacket(&data2);
}
}
}
}
}
}
break;
case DATA_ARCHIMONDEEVENT:
m_auiEncounter[4] = data;
break;
case DATA_RESET_TRASH_COUNT:
Trash = 0;
break;
case DATA_TRASH:
if (data)
Trash = data;
else
Trash--;
DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, Trash);
break;
case TYPE_RETREAT:
if (data == SPECIAL)
{
if (!m_uiAncientGemGUID.empty())
{
for (std::list<uint64>::const_iterator itr = m_uiAncientGemGUID.begin(); itr != m_uiAncientGemGUID.end(); ++itr)
{
//don't know how long it expected
DoRespawnGameObject(*itr, DAY);
}
}
}
break;
case DATA_ALLIANCE_RETREAT:
allianceRetreat = data;
HandleGameObject(HordeGate, true);
SaveToDB();
break;
case DATA_HORDE_RETREAT:
hordeRetreat = data;
HandleGameObject(ElfGate, true);
SaveToDB();
break;
case DATA_RAIDDAMAGE:
RaidDamage += data;
if (RaidDamage >= MINRAIDDAMAGE)
RaidDamage = MINRAIDDAMAGE;
break;
case DATA_RESET_RAIDDAMAGE:
RaidDamage = 0;
break;
}
//.........这里部分代码省略.........
示例14: SetBossState
bool SetBossState(uint32 type, EncounterState state)
{
if (!InstanceScript::SetBossState(type, state))
return false;
switch (type)
{
case BOSS_LEVIATHAN:
case BOSS_IGNIS:
case BOSS_RAZORSCALE:
case BOSS_XT002:
case BOSS_AURIAYA:
case BOSS_MIMIRON:
case BOSS_FREYA:
break;
case BOSS_ASSEMBLY_OF_IRON:
if (state == DONE)
HandleGameObject(ArchivumDoorGUID, true);
break;
case BOSS_VEZAX:
if (state == DONE)
HandleGameObject(VezaxDoorGUID, true);
break;
case BOSS_YOGGSARON:
break;
case BOSS_KOLOGARN:
if (state == DONE)
{
if (GameObject* gameObject = instance->GetGameObject(KologarnChestGUID))
{
gameObject->SetRespawnTime(gameObject->GetRespawnDelay());
gameObject->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
}
HandleGameObject(KologarnBridgeGUID, false);
}
break;
case BOSS_HODIR:
if (state == DONE)
{
if (GameObject* HodirRareCache = instance->GetGameObject(HodirRareCacheGUID))
if (GetData(DATA_HODIR_RARE_CACHE))
HodirRareCache->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
if (GameObject* HodirChest = instance->GetGameObject(HodirChestGUID))
HodirChest->SetRespawnTime(HodirChest->GetRespawnDelay());
HandleGameObject(HodirDoorGUID, true);
HandleGameObject(HodirIceDoorGUID, true);
}
break;
case BOSS_THORIM:
if (state == DONE)
if (GameObject* gameObject = instance->GetGameObject(ThorimChestGUID))
gameObject->SetRespawnTime(gameObject->GetRespawnDelay());
break;
case BOSS_ALGALON:
if (state == DONE)
{
_events.CancelEvent(EVENT_UPDATE_ALGALON_TIMER);
_events.CancelEvent(EVENT_DESPAWN_ALGALON);
DoUpdateWorldState(WORLD_STATE_ALGALON_TIMER_ENABLED, 0);
_algalonTimer = 61;
if (GameObject* gameObject = instance->GetGameObject(GiftOfTheObserverGUID))
gameObject->SetRespawnTime(gameObject->GetRespawnDelay());
// get item level (recheck weapons)
Map::PlayerList const& players = instance->GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
if (Player* player = itr->getSource())
for (uint8 slot = EQUIPMENT_SLOT_MAINHAND; slot <= EQUIPMENT_SLOT_RANGED; ++slot)
if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
if (item->GetTemplate()->ItemLevel > _maxWeaponItemLevel)
_maxWeaponItemLevel = item->GetTemplate()->ItemLevel;
}
else if (state == IN_PROGRESS)
{
// get item level (armor cannot be swapped in combat)
Map::PlayerList const& players = instance->GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* player = itr->getSource())
{
for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
{
if (slot == EQUIPMENT_SLOT_TABARD || slot == EQUIPMENT_SLOT_BODY)
continue;
if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
{
if (slot >= EQUIPMENT_SLOT_MAINHAND && slot <= EQUIPMENT_SLOT_RANGED)
{
if (item->GetTemplate()->ItemLevel > _maxWeaponItemLevel)
_maxWeaponItemLevel = item->GetTemplate()->ItemLevel;
}
else if (item->GetTemplate()->ItemLevel > _maxArmorItemLevel)
_maxArmorItemLevel = item->GetTemplate()->ItemLevel;
}
}
}
}
}
break;
}
//.........这里部分代码省略.........
示例15: UpdateAI
void UpdateAI(const uint32 uiDiff)
{
if(!UpdateVictim())
return;
if (!m_pInstance || m_pInstance->GetData(DATA_SAURFANG_EVENT) != IN_PROGRESS)
{
Map::PlayerList const &PlList = me->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
{
if (Player* pPlayer = i->getSource())
{
pPlayer->RemoveAurasDueToSpell(72293);
}
}
}
if (m_uiBoilingBloodTimer < uiDiff)
{
if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1))
DoCast(pTarget, SPELL_BOILING_BLOOD_10_NORMAL);
m_uiBoilingBloodTimer = 20000;
} else m_uiBoilingBloodTimer -= uiDiff;
if (m_uiBloodNovaTimer < uiDiff)
{
uint32 count = RAID_MODE(1,3,1,3);
for (uint8 i = 1; i <= count; i++)
{
Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1);
DoCast(pTarget, RAID_MODE(SPELL_BLOOD_NOVA_10_NORMAL,SPELL_BLOOD_NOVA_25_NORMAL,SPELL_BLOOD_NOVA_10_HEROIC,SPELL_BLOOD_NOVA_25_HEROIC));
m_uiBloodNovaTimer = 23000;
}
} else m_uiBloodNovaTimer -= uiDiff;
if (m_uiSummonBloodBeastTimer <= uiDiff)
{
DoCast(me, SPELL_SUMMON_BLOOD_BEAST_1);
DoCast(me, SPELL_SUMMON_BLOOD_BEAST_2);
if (getDifficulty() == RAID_DIFFICULTY_25MAN_NORMAL || getDifficulty() == RAID_DIFFICULTY_25MAN_HEROIC)
{
DoCast(me, SPELL_SUMMON_BLOOD_BEAST_3);
DoCast(me, SPELL_SUMMON_BLOOD_BEAST_4);
DoCast(me, SPELL_SUMMON_BLOOD_BEAST_5);
}
DoScriptText(SAY_BLOODBEASTS, me);
m_uiSummonBloodBeastTimer = 48000;
} else m_uiSummonBloodBeastTimer -= uiDiff;
if (me->GetPower(POWER_ENERGY) == 100)
{
Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1);
DoCast(pTarget, SPELL_FALLEN_CHAMPION);
DoScriptText(SAY_FALLENCHAMPION, me);
me->SetPower(me->getPowerType(), 0);
}
if (m_uiRuneOfBloodTimer < uiDiff)
{
Unit* pTarget = SelectUnit(SELECT_TARGET_TOPAGGRO, 0);
DoCast(pTarget, RAID_MODE(SPELL_RUNE_OF_BLOOD_10_NORMAL,SPELL_RUNE_OF_BLOOD_25_NORMAL,SPELL_RUNE_OF_BLOOD_10_HEROIC,SPELL_RUNE_OF_BLOOD_25_HEROIC));
// me->ModifyHealth(me->GetMaxHealth() * 0.05);
m_uiRuneOfBloodTimer = 40000;
} else m_uiRuneOfBloodTimer -= uiDiff;
if(me->GetHealth()*100 / me->GetMaxHealth() < 30)
{
if (!me->HasAura(SPELL_FRENZY))
{
DoCast(me, SPELL_FRENZY);
}
}
if (m_uiBerserkTimer < uiDiff)
{
DoCast(SPELL_BERSERK);
DoScriptText(SAY_BERSERK, me);
m_uiBerserkTimer = 480000;
} else m_uiBerserkTimer -= uiDiff;
DoMeleeAttackIfReady();
}