本文整理汇总了C++中map::playerlist::const_iterator::GetSource方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::GetSource方法的具体用法?C++ const_iterator::GetSource怎么用?C++ const_iterator::GetSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map::playerlist::const_iterator
的用法示例。
在下文中一共展示了const_iterator::GetSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoZoneInCombatWithPlayers
void CreatureAI::DoZoneInCombatWithPlayers(bool force)
{
Map* map = me->GetMap();
if (!map->IsDungeon())
{
sLog.outError("CreatureAI::DoZoneInCombatWithPlayers called on a map that is not an instance (creature entry = %u)", me->GetEntry());
return;
}
if (!force)
{
if (!me->CanHaveThreatList() || me->getThreatManager().isThreatListEmpty())
{
error_log("CreatureAI::DoZoneInCombatWithPlayers called for a creature that either cannot have a threat list or has empty threat list (creature entry = %u)", me->GetEntry());
return;
}
}
Map::PlayerList const &PlayerList = map->GetPlayers();
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
if (Player* pPlayer = i->GetSource())
{
if (pPlayer->IsGameMaster())
continue;
if (pPlayer->IsAlive())
{
me->SetInCombatWith(pPlayer);
pPlayer->SetInCombatWith(me);
me->AddThreat(pPlayer, 0.0f);
}
}
}
}
示例2: OnGossipHello
bool OnGossipHello(Player* player, Creature* creature)
{
if (creature->GetMap()->IsHeroic())
{
uint32 gongCounter = 0;
if (Creature* nefarianHelperheroic = creature->FindNearestCreature(NPC_NEFARIAN_HELPER_HEROIC, 150.0f, true))
nefarianHelperheroic->AI()->Talk(26);
if (Creature* gong = creature->FindNearestCreature(42949, 20.0f))
if(gongCounter < 3)
{
creature->Kill(gong);
gongCounter++;
}
}
if(Creature* atramedes = creature->FindNearestCreature(BOSS_ATRAMEDES, 200.0f))
{
creature->CastSpell(atramedes, SPELL_RESONATING_DRAGON, true);
creature->AddAura(SPELL_VERTIGO, atramedes);
creature->AddAura(SPELL_NOISY, player);
creature->CastSpell(player, SPELL_RESONATING_PLAYER, true);
Map::PlayerList const &PlayerList = creature->GetMap()->GetPlayers();
if (!PlayerList.isEmpty())
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
if (Player* playr = i->GetSource())
playr->AddAura(SPELL_SOUND_AURA, playr); // reset the bar.
creature->setDeathState(JUST_DIED);
}
return true;
}
示例3: JustDied
void JustDied(Unit* pPlayer)
{
Talk(SAY_DEAD);
char msg[250];
snprintf(msg, 250, "|cffff0000[Boss System]|r Boss|cffff6060 Lightshadow|r wurde getoetet! Respawn in 4h 33min. Darkshadow ist nun der rechtmaessige Prinz! %u", playerdie);
sWorld->SendGlobalText(msg, NULL);
Map::PlayerList const &PlList = pPlayer->GetMap()->GetPlayers();
if (PlList.isEmpty())
return;
Lootchange(playerdie);
for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
{
if (Player* player = i->GetSource())
{
if (player->IsGameMaster())
continue;
if (player->IsAlive())
{
player->RemoveAllAuras();
if (player->hasQuest(899000) && playerdie == 0){
Questcomplete();
}
else {
player->SendQuestFailed(899000,EQUIP_ERR_OK);
}
}
}
}
}
示例4: DoZoneInCombat
void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/, float maxRangeToNearestTarget /* = 50.0f*/)
{
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
{
TC_LOG_ERROR("misc", "DoZoneInCombat call for map that isn't an instance (creature entry = %d)", creature->GetTypeId() == TYPEID_UNIT ? creature->ToCreature()->GetEntry() : 0);
return;
}
if (!creature->HasReactState(REACT_PASSIVE) && !creature->GetVictim())
{
if (Unit* nearTarget = creature->SelectNearestTarget(maxRangeToNearestTarget))
creature->AI()->AttackStart(nearTarget);
else if (creature->IsSummon())
{
if (Unit* summoner = creature->ToTempSummon()->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);
}
}
}
// Intended duplicated check, the code above this should select a victim
// If it can't find a suitable attack target then we should error out.
if (!creature->HasReactState(REACT_PASSIVE) && !creature->GetVictim())
{
TC_LOG_ERROR("misc", "DoZoneInCombat called for creature that has empty threat list (creature entry = %u)", creature->GetEntry());
return;
}
Map::PlayerList const& playerList = map->GetPlayers();
if (playerList.isEmpty())
return;
for (Map::PlayerList::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
{
if (Player* player = itr->GetSource())
{
if (player->IsGameMaster())
continue;
if (player->IsAlive())
{
creature->SetInCombatWith(player);
player->SetInCombatWith(creature);
creature->AddThreat(player, 0.0f);
}
/* Causes certain things to never leave the threat list (Priest Lightwell, etc):
for (Unit::ControlList::const_iterator itr = player->m_Controlled.begin(); itr != player->m_Controlled.end(); ++itr)
{
creature->SetInCombatWith(*itr);
(*itr)->SetInCombatWith(creature);
creature->AddThreat(*itr, 0.0f);
}*/
}
}
}
示例5: UpdateAI
void UpdateAI(uint32 diff)
{
if (!UpdateVictim())
return;
if( me->GetPositionX() < 490.0f || me->GetPositionX() > 690.0f || me->GetPositionY() < 130.0f || me->GetPositionY() > 410.0f )
{
EnterEvadeMode();
return;
}
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
switch (events.GetEvent())
{
case 0:
break;
case EVENT_ACTIVATE_CONSTRUCT:
me->CastCustomSpell(SPELL_ACTIVATE_CONSTRUCT, SPELLVALUE_MAX_TARGETS, 1, (Unit*)NULL, false);
if (++counter >= 20)
{
me->MonsterYell(TEXT_BERSERK, LANG_UNIVERSAL, 0);
me->PlayDirectSound(SOUND_BERSERK);
me->CastSpell(me, SPELL_BERSERK, true);
events.PopEvent();
break;
}
events.RepeatEvent(RAID_MODE(40000,30000));
break;
case EVENT_SPELL_SCORCH:
if( rand()%2 )
{
me->MonsterYell(TEXT_SCORCH_1, LANG_UNIVERSAL, 0);
me->PlayDirectSound(SOUND_SCORCH_1);
}
else
{
me->MonsterYell(TEXT_SCORCH_2, LANG_UNIVERSAL, 0);
me->PlayDirectSound(SOUND_SCORCH_2);
}
me->SetControlled(true, UNIT_STATE_ROOT);
me->DisableRotate(true);
me->SendMovementFlagUpdate();
me->CastSpell(me->GetVictim(), S_SCORCH, false);
events.RepeatEvent(20000);
events.RescheduleEvent(EVENT_ENABLE_ROTATE, 3001);
break;
case EVENT_ENABLE_ROTATE:
me->SetControlled(false, UNIT_STATE_ROOT);
me->DisableRotate(false);
events.PopEvent();
break;
case EVENT_SPELL_FLAME_JETS:
me->MonsterTextEmote(TEXT_FLAME_JETS, 0, true);
me->CastSpell(me->GetVictim(), S_FLAME_JETS, false);
events.RepeatEvent(25000);
break;
case EVENT_GRAB:
{
std::list<Creature*> icl;
me->GetCreaturesWithEntryInRange(icl, 300.0f, NPC_IRON_CONSTRUCT);
std::vector<uint64> playerGUIDs;
Map::PlayerList const& pl = me->GetMap()->GetPlayers();
Player* temp = NULL;
for( Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr )
{
temp = itr->GetSource();
if( !temp->IsAlive() || temp->GetExactDist2d(me) > 90.0f )
continue;
if( me->GetVictim() && temp->GetGUID() == me->GetVictim()->GetGUID() )
continue;
bool found = false;
for( std::list<Creature*>::iterator itr = icl.begin(); itr != icl.end(); ++itr )
if( (*itr)->GetVictim() && (*itr)->GetVictim()->GetGUID() == temp->GetGUID() )
{
found = true;
break;
}
if( !found )
playerGUIDs.push_back(temp->GetGUID());
}
if( !playerGUIDs.empty() )
{
int8 pos = urand(0, playerGUIDs.size()-1);
if( Player* pTarget = ObjectAccessor::GetPlayer(*me,playerGUIDs.at(pos)) )
{
me->MonsterYell(TEXT_SLAG_POT, LANG_UNIVERSAL, 0);
me->PlayDirectSound(SOUND_SLAG_POT);
me->CastSpell(pTarget, SPELL_GRAB, false);
}
}
events.RepeatEvent(24000); // +6000 below
//.........这里部分代码省略.........
示例6: TeleportTransport
bool Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
{
Map const* oldMap = GetMap();
if (oldMap->GetId() != newMapid)
{
Map* newMap = sMapMgr->CreateBaseMap(newMapid);
Map::PlayerList const& oldPlayers = GetMap()->GetPlayers();
if (!oldPlayers.isEmpty())
{
UpdateData data(GetMapId());
BuildOutOfRangeUpdateBlock(&data);
WorldPacket packet;
data.BuildPacket(&packet);
for (Map::PlayerList::const_iterator itr = oldPlayers.begin(); itr != oldPlayers.end(); ++itr)
if (itr->GetSource()->GetTransport() != this)
itr->GetSource()->SendDirectMessage(&packet);
}
UnloadStaticPassengers();
GetMap()->RemoveFromMap<Transport>(this, false);
SetMap(newMap);
Map::PlayerList const& newPlayers = GetMap()->GetPlayers();
if (!newPlayers.isEmpty())
{
for (Map::PlayerList::const_iterator itr = newPlayers.begin(); itr != newPlayers.end(); ++itr)
{
if (itr->GetSource()->GetTransport() != this)
{
UpdateData data(newMapid);
BuildCreateUpdateBlockForPlayer(&data, itr->GetSource());
WorldPacket packet;
data.BuildPacket(&packet);
itr->GetSource()->SendDirectMessage(&packet);
}
}
}
for (std::set<WorldObject*>::iterator itr = _passengers.begin(); itr != _passengers.end();)
{
WorldObject* obj = (*itr++);
float destX, destY, destZ, destO;
obj->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, GetOrientation());
switch (obj->GetTypeId())
{
case TYPEID_PLAYER:
if (!obj->ToPlayer()->TeleportTo(newMapid, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT))
_passengers.erase(obj);
break;
default:
RemovePassenger(obj);
break;
}
}
Relocate(x, y, z, GetOrientation());
GetMap()->AddToMap<Transport>(this);
return true;
}
else
{
UpdatePosition(x, y, z, GetOrientation());
return false;
}
}
示例7: UpdateAI
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
if (events.IsInPhase(PHASE_NORMAL))
{
case EVENT_BLOODTHIRST:
DoCast(me, SPELL_BLOODTHIRST);
events.ScheduleEvent(EVENT_BLOODTHIRST, 10000);
break;
case EVENT_FLAME_SPHERE:
DoCastVictim(SPELL_CONJURE_FLAME_SPHERE);
events.SetPhase(PHASE_SPECIAL);
events.ScheduleEvent(EVENT_CASTING_FLAME_SPHERES, 3000);
events.ScheduleEvent(EVENT_FLAME_SPHERE, 15000);
break;
case EVENT_VANISH:
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
uint32 targets = 0;
for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
{
Player* player = i->GetSource();
if (player && player->IsAlive())
++targets;
}
if (targets > 2)
{
Talk(SAY_VANISH);
DoCast(me, SPELL_VANISH);
events.SetPhase(PHASE_SPECIAL);
events.ScheduleEvent(EVENT_JUST_VANISHED, 500);
if (Unit* embraceTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
_embraceTargetGUID = embraceTarget->GetGUID();
}
events.ScheduleEvent(EVENT_VANISH, urand(25000, 35000));
break;
}
}
case EVENT_CASTING_FLAME_SPHERES:
{
events.SetPhase(PHASE_NORMAL);
Unit* sphereTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
if (!sphereTarget)
break;
float angle, x, y;
//DoCast(me, SPELL_FLAME_SPHERE_SUMMON_1);
if (Creature* sphere = DoSpawnCreature(CREATURE_FLAME_SPHERE, 0, 0, 5, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 10 * IN_MILLISECONDS))
{
angle = sphere->GetAngle(sphereTarget);
x = sphere->GetPositionX() + DATA_SPHERE_DISTANCE * std::cos(angle);
y = sphere->GetPositionY() + DATA_SPHERE_DISTANCE * std::sin(angle);
sphere->GetMotionMaster()->MovePoint(0, x, y, sphere->GetPositionZ());
}
if (IsHeroic())
{
//DoCast(me, H_SPELL_FLAME_SPHERE_SUMMON_1);
if (Creature* sphere = DoSpawnCreature(H_CREATURE_FLAME_SPHERE_1, 0, 0, 5, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 10 * IN_MILLISECONDS))
{
angle = sphere->GetAngle(sphereTarget) + DATA_SPHERE_ANGLE_OFFSET;
x = sphere->GetPositionX() + DATA_SPHERE_DISTANCE/2 * std::cos(angle);
y = sphere->GetPositionY() + DATA_SPHERE_DISTANCE/2 * std::sin(angle);
sphere->GetMotionMaster()->MovePoint(0, x, y, sphere->GetPositionZ());
}
//DoCast(me, H_SPELL_FLAME_SPHERE_SUMMON_2);
if (Creature* sphere = DoSpawnCreature(H_CREATURE_FLAME_SPHERE_2, 0, 0, 5, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 10 * IN_MILLISECONDS))
{
angle = sphere->GetAngle(sphereTarget) - DATA_SPHERE_ANGLE_OFFSET;
x = sphere->GetPositionX() + DATA_SPHERE_DISTANCE/2 * std::cos(angle);
y = sphere->GetPositionY() + DATA_SPHERE_DISTANCE/2 * std::sin(angle);
sphere->GetMotionMaster()->MovePoint(0, x, y, sphere->GetPositionZ());
}
}
break;
}
case EVENT_JUST_VANISHED:
if (Unit* embraceTarget = GetEmbraceTarget())
{
me->GetMotionMaster()->Clear();
me->SetSpeed(MOVE_WALK, 2.0f, true);
me->GetMotionMaster()->MoveChase(embraceTarget);
}
events.ScheduleEvent(EVENT_VANISHED, 1300);
break;
case EVENT_VANISHED:
//.........这里部分代码省略.........
示例8: SendNonChatPacket
void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly) const
{
float dist = GetRangeForChatType(msgType);
switch (msgType)
{
case CHAT_MSG_MONSTER_WHISPER:
case CHAT_MSG_RAID_BOSS_WHISPER:
{
if (range == TEXT_RANGE_NORMAL)//ignores team and gmOnly
{
if (!whisperTarget || whisperTarget->GetTypeId() != TYPEID_PLAYER)
return;
whisperTarget->ToPlayer()->GetSession()->SendPacket(data);
return;
}
break;
}
default:
break;
}
switch (range)
{
case TEXT_RANGE_AREA:
{
uint32 areaId = source->GetAreaId();
Map::PlayerList const& players = source->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
if (itr->GetSource()->GetAreaId() == areaId && (!team || Team(itr->GetSource()->GetTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
itr->GetSource()->GetSession()->SendPacket(data);
return;
}
case TEXT_RANGE_ZONE:
{
uint32 zoneId = source->GetZoneId();
Map::PlayerList const& players = source->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
if (itr->GetSource()->GetZoneId() == zoneId && (!team || Team(itr->GetSource()->GetTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
itr->GetSource()->GetSession()->SendPacket(data);
return;
}
case TEXT_RANGE_MAP:
{
Map::PlayerList const& players = source->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
if ((!team || Team(itr->GetSource()->GetTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
itr->GetSource()->GetSession()->SendPacket(data);
return;
}
case TEXT_RANGE_WORLD:
{
SessionMap const& smap = sWorld->GetAllSessions();
for (SessionMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter)
if (Player* player = iter->second->GetPlayer())
if (player->GetSession() && (!team || Team(player->GetTeam()) == team) && (!gmOnly || player->IsGameMaster()))
player->GetSession()->SendPacket(data);
return;
}
case TEXT_RANGE_NORMAL:
default:
break;
}
source->SendMessageToSetInRange(data, dist, true);
}
示例9: UpdateAI
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_BLOODTHIRST:
DoCast(me, SPELL_BLOODTHIRST);
events.ScheduleEvent(EVENT_BLOODTHIRST, 10000);
break;
case EVENT_CONJURE_FLAME_SPHERES:
// random target?
if (Unit* victim = me->GetVictim())
{
_flameSphereTargetGUID = victim->GetGUID();
DoCast(victim, SPELL_CONJURE_FLAME_SPHERE);
}
events.ScheduleEvent(EVENT_CONJURE_FLAME_SPHERES, 15000);
break;
case EVENT_VANISH:
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
uint32 targets = 0;
for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
{
Player* player = i->GetSource();
if (player && player->IsAlive())
++targets;
}
if (targets > 2)
{
Talk(SAY_VANISH);
DoCast(me, SPELL_VANISH);
me->SetInCombatState(true); // Prevents the boss from resetting
events.DelayEvents(500);
events.ScheduleEvent(EVENT_JUST_VANISHED, 500);
if (Unit* embraceTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true))
_embraceTargetGUID = embraceTarget->GetGUID();
}
events.ScheduleEvent(EVENT_VANISH, urand(25000, 35000));
break;
}
case EVENT_JUST_VANISHED:
if (Unit* embraceTarget = GetEmbraceTarget())
{
me->GetMotionMaster()->Clear();
me->SetSpeed(MOVE_WALK, 2.0f, true);
me->GetMotionMaster()->MoveChase(embraceTarget);
}
events.ScheduleEvent(EVENT_VANISHED, 1300);
break;
case EVENT_VANISHED:
if (Unit* embraceTarget = GetEmbraceTarget())
DoCast(embraceTarget, SPELL_EMBRACE_OF_THE_VAMPYR);
Talk(SAY_FEED);
me->GetMotionMaster()->Clear();
me->SetSpeed(MOVE_WALK, 1.0f, true);
me->GetMotionMaster()->MoveChase(me->GetVictim());
events.ScheduleEvent(EVENT_FEEDING, 20000);
break;
case EVENT_FEEDING:
_embraceTargetGUID.Clear();
break;
default:
break;
}
}
DoMeleeAttackIfReady();
}
示例10: 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:
break;
case BOSS_MIMIRON:
if (state == DONE)
instance->SummonCreature(NPC_MIMIRON_OBSERVATION_RING, ObservationRingKeepersPos[3]);
break;
case BOSS_FREYA:
if (state == DONE)
instance->SummonCreature(NPC_FREYA_OBSERVATION_RING, ObservationRingKeepersPos[0]);
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_YOGG_SARON:
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);
instance->SummonCreature(NPC_HODIR_OBSERVATION_RING, ObservationRingKeepersPos[1]);
}
break;
case BOSS_THORIM:
if (state == DONE)
{
if (GameObject* gameObject = instance->GetGameObject(ThorimChestGUID))
gameObject->SetRespawnTime(gameObject->GetRespawnDelay());
instance->SummonCreature(NPC_THORIM_OBSERVATION_RING, ObservationRingKeepersPos[2]);
}
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)
{
//.........这里部分代码省略.........
示例11: UpdateAI
void UpdateAI(uint32 diff)
{
if (wipe_timer <= diff)
{
if (me->GetInstanceScript() && me->GetInstanceScript()->GetData(TYPE_IS_WIPE))
{
me->GetInstanceScript()->SetData(TYPE_IS_WIPE, 1);
wipe_timer = 2000;
}
}
else
wipe_timer -= diff;
if (!UpdateVictim())
return;
events.Update(diff);
if (me->GetHealthPct() < 70.f && status == PHASE_1)
{
me->AddAura(SPELL_JADE_ESSENCE, me);
events.Reset();
events.ScheduleEvent(EVENT_JADE_SERPENT_STRIKE, 5000);
events.ScheduleEvent(EVENT_JADE_SERPENT_KICK, 10000);
Talk(TALK_EVENT_01);
status = PHASE_2;
}
if (me->GetHealthPct() < 30.f && status == PHASE_2)
{
events.Reset();
events.ScheduleEvent(EVENT_SUMMON_YULON, 500);
Talk(TALK_EVENT_02);
status = PHASE_3;
}
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_SERPENT_STRIKE:
{
me->CastSpell(me->GetVictim(), SPELL_SERPENT_STRIKE, false);
Map::PlayerList const& PlayerList = me->GetInstanceScript()->instance->GetPlayers();
if (!PlayerList.isEmpty())
{
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
Player* plr = i->GetSource();
if (!plr)
continue;
if (plr->GetDistance2d(me) < 10.f)
plr->KnockbackFrom(me->GetPositionX(), me->GetPositionY(), 10, 10);
}
}
events.ScheduleEvent(EVENT_SERPENT_STRIKE, 10000);
events.ScheduleEvent(EVENT_SERPENT_WAVE, 4000);
}
break;
case EVENT_SERPENT_KICK:
me->CastSpell(me->GetVictim(), SPELL_SERPENT_KICK, false);
events.ScheduleEvent(EVENT_SERPENT_KICK, 10000);
break;
case EVENT_SERPENT_WAVE:
{
TempSummon* sum = nullptr;
sum = me->SummonCreature(CREATURE_TRIGGER_WAVE, 932.775f, -2548.743f, 179.821f, 1.254f);
if (sum)
{
sum->SetDisplayId(11686);
sum->CastSpell(sum, SPELL_SERPENT_WAVE_VISUAL, false);
sum->CastSpell(sum, SPELL_SERPENT_WAVE_PERIODIC, false);
sum->GetMotionMaster()->MovePoint(0, 939.796f, -2530.586f, 179.941f);
sum->DespawnOrUnsummon(3200);
}
sum = me->SummonCreature(CREATURE_TRIGGER_WAVE, 940.014f, -2564.114f, 179.821f, 5.978f);
if (sum)
{
sum->SetDisplayId(11686);
sum->CastSpell(sum, SPELL_SERPENT_WAVE_VISUAL, false);
sum->CastSpell(sum, SPELL_SERPENT_WAVE_PERIODIC, false);
sum->GetMotionMaster()->MovePoint(0, 957.711f, -2570.030f, 179.941f);
sum->DespawnOrUnsummon(3200);
}
sum = me->SummonCreature(CREATURE_TRIGGER_WAVE, 925.971f, -2572.423f, 179.821f, 4.395f);
if (sum)
{
sum->SetDisplayId(11686);
sum->CastSpell(sum, SPELL_SERPENT_WAVE_VISUAL, false);
sum->CastSpell(sum, SPELL_SERPENT_WAVE_PERIODIC, false);
sum->GetMotionMaster()->MovePoint(0, 919.606f, -2591.245f, 179.941f);
sum->DespawnOrUnsummon(3200);
}
sum = me->SummonCreature(CREATURE_TRIGGER_WAVE, 918.923f, -2557.356f, 179.821f, 2.821f);
if (sum)
{
sum->SetDisplayId(11686);
sum->CastSpell(sum, SPELL_SERPENT_WAVE_VISUAL, false);
sum->CastSpell(sum, SPELL_SERPENT_WAVE_PERIODIC, false);
//.........这里部分代码省略.........
示例12: UpdateAI
void UpdateAI(uint32 diff)
{
events.Update(diff);
uint32 eventId = events.GetEvent();
if (eventId == EVENT_SPELL_INHIBIT_MAGIC)
{
Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
if (Player* player = i->GetSource())
{
float dist = me->GetDistance(player);
if (player->IsAlive() && dist < 45.0f)
{
Aura* aura = player->GetAura(SPELL_INHIBIT_MAGIC);
if (!aura)
aura = me->AddAura(SPELL_INHIBIT_MAGIC, player);
else
aura->RefreshDuration();
if (aura)
aura->SetStackAmount(getStackCount(dist));
}
else
player->RemoveAurasDueToSpell(SPELL_INHIBIT_MAGIC);
}
events.RepeatEvent(3000);
return;
}
if (!UpdateVictim())
return;
switch (eventId)
{
case EVENT_SPELL_ATTRACT_MAGIC:
me->CastSpell(me, SPELL_ATTRACT_MAGIC, false);
events.RepeatEvent(30000);
events.RescheduleEvent(EVENT_SPELL_CARNIVOROUS, 1500);
break;
case EVENT_SPELL_CARNIVOROUS:
me->CastSpell(me, DUNGEON_MODE(SPELL_CARNIVOROUS_BITE_N, SPELL_CARNIVOROUS_BITE_H), false);
events.RepeatEvent(10000);
break;
case EVENT_SPELL_FOCUS_FIRE:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 60.0f, true))
{
if (Creature* cr = me->SummonCreature(ENTRY_FOCUS_FIRE, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 7000))
focusGUID = cr->GetGUID();
Talk(EMOTE_FOCUSED, target);
}
events.RepeatEvent(urand(15000, 20000));
events.ScheduleEvent(EVENT_SPELL_FOCUS_FIRE_2, 3000);
events.ScheduleEvent(EVENT_SPELL_FOCUS_FIRE_2, 3500);
events.ScheduleEvent(EVENT_SPELL_FOCUS_FIRE_2, 4000);
events.ScheduleEvent(EVENT_SPELL_FOCUS_FIRE_3, 5000);
me->SetControlled(true, UNIT_STATE_ROOT);
break;
case EVENT_SPELL_FOCUS_FIRE_2:
if (Unit* flare = ObjectAccessor::GetCreature(*me, focusGUID))
me->CastSpell(flare, SPELL_FOCUS_CAST, true);
events.PopEvent();
break;
case EVENT_SPELL_FOCUS_FIRE_3:
me->SetControlled(false, UNIT_STATE_ROOT);
events.PopEvent();
break;
}
DoMeleeAttackIfReady();
}
示例13: UpdateAI
void UpdateAI(const uint32 diff)
{
//Inhibitmagic_Timer
if (Inhibitmagic_Timer <= diff)
{
float dist;
Map* map = me->GetMap();
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() && (dist = i_pl->IsWithinDist(me, 45)))
{
i_pl->RemoveAurasDueToSpell(SPELL_INHIBITMAGIC);
me->AddAura(SPELL_INHIBITMAGIC, i_pl);
if (dist < 35)
me->AddAura(SPELL_INHIBITMAGIC, i_pl);
if (dist < 25)
me->AddAura(SPELL_INHIBITMAGIC, i_pl);
if (dist < 15)
me->AddAura(SPELL_INHIBITMAGIC, i_pl);
}
Inhibitmagic_Timer = 3000+(rand()%1000);
} else Inhibitmagic_Timer -= diff;
//Return since we have no target
if (!UpdateVictim())
return;
//Attractmagic_Timer
if (Attractmagic_Timer <= diff)
{
DoCast(me, SPELL_ATTRACTMAGIC);
Attractmagic_Timer = 30000;
Carnivorousbite_Timer = 1500;
} else Attractmagic_Timer -= diff;
//Carnivorousbite_Timer
if (Carnivorousbite_Timer <= diff)
{
DoCast(me, SPELL_CARNIVOROUSBITE);
Carnivorousbite_Timer = 10000;
} else Carnivorousbite_Timer -= diff;
//FocusFire_Timer
if (FocusFire_Timer <= diff)
{
// Summon Focus Fire & Emote
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1);
if (target && target->GetTypeId() == TYPEID_PLAYER && target->IsAlive())
{
FocusedTargetGUID = target->GetGUID();
me->SummonCreature(ENTRY_FOCUS_FIRE, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 5500);
// TODO: Find better way to handle emote
// Emote
std::string emote(EMOTE_FOCUSES_ON);
emote.append(target->GetName());
emote.push_back('!');
me->MonsterTextEmote(emote, 0, true);
}
FocusFire_Timer = 15000+(rand()%5000);
} else FocusFire_Timer -= diff;
DoMeleeAttackIfReady();
}
示例14: UpdateAI
void UpdateAI(uint32 diff)
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_SHIMMER:
{
// Remove old vulnerabilty spell
if (CurrentVurln_Spell)
me->RemoveAurasDueToSpell(CurrentVurln_Spell);
// Cast new random vulnerabilty on self
uint32 spell = RAND(SPELL_FIRE_VULNERABILITY, SPELL_FROST_VULNERABILITY, SPELL_SHADOW_VULNERABILITY, SPELL_NATURE_VULNERABILITY, SPELL_ARCANE_VULNERABILITY);
DoCast(me, spell);
CurrentVurln_Spell = spell;
Talk(EMOTE_SHIMMER);
events.ScheduleEvent(EVENT_SHIMMER, 45000);
break;
}
case EVENT_BREATH_1:
DoCastVictim(Breath1_Spell);
events.ScheduleEvent(EVENT_BREATH_1, 60000);
break;
case EVENT_BREATH_2:
DoCastVictim(Breath2_Spell);
events.ScheduleEvent(EVENT_BREATH_2, 60000);
break;
case EVENT_AFFLICTION:
{
Map::PlayerList const &players = me->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* player = itr->GetSource()->ToPlayer())
{
DoCast(player, RAND(SPELL_BROODAF_BLUE, SPELL_BROODAF_BLACK, SPELL_BROODAF_RED, SPELL_BROODAF_BRONZE, SPELL_BROODAF_GREEN), true);
if (player->HasAura(SPELL_BROODAF_BLUE) &&
player->HasAura(SPELL_BROODAF_BLACK) &&
player->HasAura(SPELL_BROODAF_RED) &&
player->HasAura(SPELL_BROODAF_BRONZE) &&
player->HasAura(SPELL_BROODAF_GREEN))
{
DoCast(player, SPELL_CHROMATIC_MUT_1);
}
}
}
}
events.ScheduleEvent(EVENT_AFFLICTION, 10000);
break;
case EVENT_FRENZY:
DoCast(me, SPELL_FRENZY);
events.ScheduleEvent(EVENT_FRENZY, urand(10000, 15000));
break;
}
}
// Enrage if not already enraged and below 20%
if (!Enraged && HealthBelowPct(20))
{
DoCast(me, SPELL_ENRAGE);
Enraged = true;
}
DoMeleeAttackIfReady();
}
示例15: UpdateAI
void UpdateAI(uint32 diff)
{
if (!pInstance || !UpdateVictim())
return;
Summons.DespawnAll();
events.Update(diff);
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_LIGHTNING_BOLT:
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
DoCastVictim(SPELL_LIGHTNING_BOLT);
events.ScheduleEvent(EVENT_LIGHTNING_BOLT, 2000);
break;
case EVENT_CALL_VORTEX:
for (uint8 i = 0; i < 8; i++)
if (_vortexes[i])
{
float _angle;
_angle = me->GetAngle(_vortexes[i]->GetPositionX(), _vortexes[i]->GetPositionY());
Position _pos = me->GetNearPosition(5.0f, _angle);
_vortexes[i]->GetMotionMaster()->MovementExpired(false);
_vortexes[i]->GetMotionMaster()->MovePoint(1, _pos);
}
events.ScheduleEvent(EVENT_RESET_VORTEX, urand(14000, 17000));
break;
case EVENT_RESET_VORTEX:
for (uint8 i = 0; i < 8; i++)
if (_vortexes[i])
{
_vortexes[i]->GetMotionMaster()->MovementExpired(false);
_vortexes[i]->GetMotionMaster()->MovePoint(2, ertanvortexPos_1[i]);
}
events.ScheduleEvent(EVENT_CALL_VORTEX, urand(20000, 25000));
break;
case EVENT_STORM_EDGE:
_distance = me->GetDistance2d(_vortexes[1]);
if (me->GetMap()->GetPlayers().isEmpty())
return;
for (Map::PlayerList::const_iterator itr = me->GetMap()->GetPlayers().begin(); itr != me->GetMap()->GetPlayers().end(); ++itr)
{
if (Player* pPlayer = itr->GetSource())
{
if (me->GetDistance2d(pPlayer) > _distance)
{
//uint8 i = urand(0, 7);
//if (_vortexes[i])
//_vortexes[i]->CastSpell(itr->GetSource(), SPELL_STORM_EDGE, true);
DoCast(pPlayer, SPELL_STORM_EDGE, true);
}
}
}
events.ScheduleEvent(EVENT_STORM_EDGE, 2000);
break;
}
}
}