本文整理汇总了C++中CreatureList::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ CreatureList::begin方法的具体用法?C++ CreatureList::begin怎么用?C++ CreatureList::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CreatureList
的用法示例。
在下文中一共展示了CreatureList::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoSortArmyWaves
void instance_ruins_of_ahnqiraj::DoSortArmyWaves()
{
CreatureList lCreatureList;
// Sort the 7 army waves
// We need to use gridsearcher for this, because coords search is too complicated here
for (uint8 i = 0; i < MAX_ARMY_WAVES; ++i)
{
// Clear all the army waves
m_sArmyWavesGuids[i].clear();
lCreatureList.clear();
if (Creature* pTemp = GetSingleCreatureFromStorage(aArmySortingParameters[i].m_uiEntry))
{
GetCreatureListWithEntryInGrid(lCreatureList, pTemp, NPC_QIRAJI_WARRIOR, aArmySortingParameters[i].m_fSearchDist);
GetCreatureListWithEntryInGrid(lCreatureList, pTemp, NPC_SWARMGUARD_NEEDLER, aArmySortingParameters[i].m_fSearchDist);
for (CreatureList::const_iterator itr = lCreatureList.begin(); itr != lCreatureList.end(); ++itr)
{
if ((*itr)->isAlive())
m_sArmyWavesGuids[i].insert((*itr)->GetObjectGuid());
}
if (pTemp->isAlive())
m_sArmyWavesGuids[i].insert(pTemp->GetObjectGuid());
}
}
// send the first wave
m_uiCurrentArmyWave = 0;
DoSendNextArmyWave();
}
示例2: GetCreatureListWithEntryInGrid
Creature *RespawnNearbyBugsAndGetOne()
{
CreatureList lUnitList;
GetCreatureListWithEntryInGrid(lUnitList,m_creature,15316,150.0f);
GetCreatureListWithEntryInGrid(lUnitList,m_creature,15317,150.0f);
if (lUnitList.empty())
return NULL;
Creature *nearb = NULL;
for(CreatureList::iterator iter = lUnitList.begin(); iter != lUnitList.end(); ++iter)
{
Creature *c = (Creature *)(*iter);
if (c->isDead())
{
c->Respawn();
c->setFaction(7);
c->RemoveAllAuras();
}
if (c->IsWithinDistInMap(m_creature, ABUSE_BUG_RANGE))
{
if (!nearb || !urand(0, 3))
nearb = c;
}
}
return nearb;
}
示例3: GOHello_go_altar_of_keepers
bool GOHello_go_altar_of_keepers(Player* pPlayer, GameObject* pGo)
{
if (!pPlayer || !pGo)
return false;
pPlayer->CastSpell(pPlayer, SPELL_USE_ALTAR_VISUAL, true);
CreatureList lStoneKeepers;
GetCreatureListWithEntryInGrid(lStoneKeepers, pGo, NPC_STONE_KEEPER, HALL_RADIUS);
if (!lStoneKeepers.empty())
{
for(CreatureList::iterator itr = lStoneKeepers.begin(); itr != lStoneKeepers.end(); ++itr)
{
if (*itr && (*itr)->isAlive())
{
(*itr)->setFaction(FACTION_TITAN_UNFRIENDLY);
(*itr)->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
(*itr)->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
if ((*itr)->AI())
{
(*itr)->RemoveAurasDueToSpell(SPELL_STONED);
(*itr)->AI()->AttackStart(pPlayer);
}
}
}
}
return false;
}
示例4: EnterEvadeMode
void EnterEvadeMode()
{
CreatureList adds;
GetCreatureListWithEntryInGrid(adds, m_creature, NPC_ADD, 50.0f);
if (!adds.empty())
for(CreatureList::iterator iter = adds.begin(); iter != adds.end(); ++iter)
(*iter)->ForcedDespawn();
m_creature->GetMotionMaster()->MoveTargetedHome();
}
示例5: DespawnSphere
void DespawnSphere()
{
CreatureList assistList;
GetCreatureListWithEntryInGrid(assistList,m_creature, NPC_ETHEREAL_SPHERE ,150.0f);
if (assistList.empty())
return;
for(CreatureList::iterator iter = assistList.begin(); iter != assistList.end(); ++iter)
(*iter)->DealDamage((*iter), (*iter)->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
}
示例6: DespawnAdds
void DespawnAdds()
{
CreatureList pWorshippers;
GetCreatureListWithEntryInGrid(pWorshippers, m_creature, NPC_WORSHIPPER, DEFAULT_VISIBILITY_INSTANCE);
if (!pWorshippers.empty())
for(CreatureList::iterator itr = pWorshippers.begin(); itr != pWorshippers.end(); ++itr)
{
(*itr)->ForcedDespawn();
}
CreatureList pFollower;
GetCreatureListWithEntryInGrid(pFollower, m_creature, NPC_FOLLOWER, DEFAULT_VISIBILITY_INSTANCE);
if (!pFollower.empty())
for(CreatureList::iterator iter = pFollower.begin(); iter != pFollower.end(); ++iter)
{
(*iter)->ForcedDespawn();
}
}
示例7: DamageTaken
void DamageTaken(Unit* pDoneBy, uint32& uiDamage, DamageEffectType /*damagetype*/) override
{
if (uiDamage > m_creature->GetHealth() || m_creature->GetHealthPercent() < 20.0f)
{
if (Player* pPlayer = pDoneBy->GetBeneficiaryPlayer())
{
if (pPlayer->GetQuestStatus(QUEST_MISSING_DIPLO_PT16) == QUEST_STATUS_INCOMPLETE)
guidPlayer = pPlayer->GetObjectGuid(); // Store the player to give quest credit later
}
uiDamage = 0;
DoScriptText(EMOTE_SURRENDER, m_creature);
EnterEvadeMode();
// Make the two sentries flee and despawn
CreatureList lSentryList;
GetCreatureListWithEntryInGrid(lSentryList, m_creature, NPC_SENTRY, 40.0f);
for (CreatureList::const_iterator itr = lSentryList.begin(); itr != lSentryList.end(); ++itr)
{
if ((*itr)->isAlive())
{
(*itr)->RemoveAllAurasOnEvade();
(*itr)->CombatStop(true);
(*itr)->SetWalk(false);
(*itr)->GetMotionMaster()->MovePoint(0, fSentryFleePoint[0], fSentryFleePoint[1], fSentryFleePoint[2]);
(*itr)->ForcedDespawn(4000);
}
}
// Summon Jaina Proudmoore, Archmage Tervosh and Pained
for (const auto& lOutroSpawn : lOutroSpawns)
{
Creature* pCreature = m_creature->SummonCreature(lOutroSpawn.uiEntry, lOutroSpawn.fX, lOutroSpawn.fY, lOutroSpawn.fZ, lOutroSpawn.fO, TEMPSPAWN_TIMED_DESPAWN, 3 * MINUTE * IN_MILLISECONDS, false, true);
if (pCreature)
{
pCreature->CastSpell(pCreature, SPELL_TELEPORT_VISUAL, TRIGGERED_NONE);
pCreature->GetMotionMaster()->MovePoint(0, lOutroSpawn.fDestX, lOutroSpawn.fDestY, lOutroSpawn.fDestZ);
// Exception case for Archmage Tervosh: the outro event is a simple speech with visual spell cast
// so it will be handled by a DBScript held by NPC Archmage Tervosh
if (pCreature->GetEntry() == NPC_TERVOSH)
{
// Remove Gossip and Quest Giver flag from now, they will be re-added later to Archmage Tervosh in DBScript
pCreature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER | UNIT_NPC_FLAG_GOSSIP);
// The DBScript will be done here
pCreature->GetMotionMaster()->MoveWaypoint(0);
}
}
}
}
}
示例8: ShowMushrooms
void ShowMushrooms(bool show = true)
{
CreatureList lMushroomsHealthy;
GetCreatureListWithEntryInGrid(lMushroomsHealthy, m_creature, NPC_HEALTHY_MUSHROOM, 150.0f);
for(CreatureList::iterator itr1 = lMushroomsHealthy.begin(); itr1 != lMushroomsHealthy.end(); ++itr1)
{
if (show)
(*itr1)->SetVisibility(VISIBILITY_ON);
else
(*itr1)->SetVisibility(VISIBILITY_OFF);
}
CreatureList lMushroomsPoison;
GetCreatureListWithEntryInGrid(lMushroomsPoison, m_creature, NPC_POISONOUS_MUSHROOM, 150.0f);
for(CreatureList::iterator itr2 = lMushroomsPoison.begin(); itr2 != lMushroomsPoison.end(); ++itr2)
{
if (show)
(*itr2)->SetVisibility(VISIBILITY_ON);
else
(*itr2)->SetVisibility(VISIBILITY_OFF);
}
}
示例9: SelectRandomCreatureOfEntryInRange
Creature* SelectRandomCreatureOfEntryInRange(uint32 uiEntry, float fRange)
{
CreatureList lCreatureList;
GetCreatureListWithEntryInGrid(lCreatureList, m_creature, uiEntry, fRange);
if (lCreatureList.empty())
return NULL;
CreatureList::iterator iter = lCreatureList.begin();
advance(iter, urand(0, lCreatureList.size()-1));
return *iter;
}
示例10: DoEncounterCleanup
// function to cleanup the world states and GO flags
void DoEncounterCleanup()
{
// remove world state
if (Player* pSummoner = m_creature->GetMap()->GetPlayer(m_summonerGuid))
pSummoner->SendUpdateWorldState(WORLD_STATE_TETHYR_SHOW, 0);
// reset all cannons
GameObjectList lCannonsInRange;
GetGameObjectListWithEntryInGrid(lCannonsInRange, m_creature, GO_COVE_CANNON, 100.0f);
for (GameObjectList::const_iterator itr = lCannonsInRange.begin(); itr != lCannonsInRange.end(); ++itr)
(*itr)->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
// despawn all marksmen
CreatureList lMarksmenInRange;
GetCreatureListWithEntryInGrid(lMarksmenInRange, m_creature, NPC_THERAMORE_MARKSMAN, 100.0f);
for (CreatureList::const_iterator itr = lMarksmenInRange.begin(); itr != lMarksmenInRange.end(); ++itr)
(*itr)->ForcedDespawn(30000);
}
示例11: MovementInform
void MovementInform(uint32 uiMotionType, uint32 uiPointId) override
{
if (uiMotionType == WAYPOINT_MOTION_TYPE)
{
// start attacking
if (uiPointId == 12)
{
// make cannons usable
GameObjectList lCannonsInRange;
GetGameObjectListWithEntryInGrid(lCannonsInRange, m_creature, GO_COVE_CANNON, 100.0f);
for (GameObjectList::const_iterator itr = lCannonsInRange.begin(); itr != lCannonsInRange.end(); ++itr)
(*itr)->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
// attack all marksmen
CreatureList lMarksmenInRange;
GetCreatureListWithEntryInGrid(lMarksmenInRange, m_creature, NPC_THERAMORE_MARKSMAN, 100.0f);
for (CreatureList::const_iterator itr = lMarksmenInRange.begin(); itr != lMarksmenInRange.end(); ++itr)
{
(*itr)->AI()->AttackStart(m_creature);
AttackStart(*itr);
}
}
}
else if (uiMotionType == POINT_MOTION_TYPE)
{
// Spout on cannon point reach
if (uiPointId)
{
if (DoCastSpellIfCan(m_creature, urand(0, 1) ? SPELL_SPOUT_LEFT : SPELL_SPOUT_RIGHT, CAST_INTERRUPT_PREVIOUS) == CAST_OK)
{
// Remove the target focus
m_creature->SetTarget(nullptr);
m_uiPhase = PHASE_SPOUT;
}
}
}
}
示例12: DeleteCreaturesAndRemoveAuras
void npc_toc_announcerAI::DeleteCreaturesAndRemoveAuras()
{
CreatureList deleteList;
GetCreatureListWithEntryInGrid(deleteList, m_creature, NPC_LIGHT_ESSENCE, DEFAULT_VISIBILITY_INSTANCE);
GetCreatureListWithEntryInGrid(deleteList, m_creature, NPC_DARK_ESSENCE, DEFAULT_VISIBILITY_INSTANCE);
GetCreatureListWithEntryInGrid(deleteList, m_creature, NPC_CONCENTRATED_LIGHT, DEFAULT_VISIBILITY_INSTANCE);
GetCreatureListWithEntryInGrid(deleteList, m_creature, NPC_CONCENTRATED_DARKNESS, DEFAULT_VISIBILITY_INSTANCE);
GetCreatureListWithEntryInGrid(deleteList, m_creature, NPC_MISTRESS_OF_PAIN, DEFAULT_VISIBILITY_INSTANCE);
GetCreatureListWithEntryInGrid(deleteList, m_creature, NPC_FELFLAME_INFERNAL, DEFAULT_VISIBILITY_INSTANCE);
// clean up useless corpses
GetCreatureListWithEntryInGrid(deleteList, m_creature, NPC_GORMOK, DEFAULT_VISIBILITY_INSTANCE);
GetCreatureListWithEntryInGrid(deleteList, m_creature, NPC_ACIDMAW, DEFAULT_VISIBILITY_INSTANCE);
GetCreatureListWithEntryInGrid(deleteList, m_creature, NPC_DREADSCALE, DEFAULT_VISIBILITY_INSTANCE);
for(CreatureList::iterator itr = deleteList.begin(); itr != deleteList.end(); ++itr)
(*itr)->ForcedDespawn(3500);
Map::PlayerList const &PlayerList = m_pInstance->instance->GetPlayers();
if (!PlayerList.isEmpty())
for (Map::PlayerList::const_iterator iter = PlayerList.begin(); iter != PlayerList.end(); ++iter)
if (Player* plr = iter->getSource())
for (uint8 d = 0; d < 12; ++d)
plr->RemoveAurasDueToSpell(Dispell[d]);
}
示例13: QuestAccept_npc_private_hendel
bool QuestAccept_npc_private_hendel(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
{
if (pQuest->GetQuestId() == QUEST_MISSING_DIPLO_PT16)
{
pCreature->SetFactionTemporary(FACTION_HOSTILE, TEMPFACTION_RESTORE_COMBAT_STOP | TEMPFACTION_RESTORE_RESPAWN);
pCreature->AI()->AttackStart(pPlayer);
// Find the nearby sentries in order to make them attack
// The two sentries are linked to Private Hendel in DB to ensure they respawn together
CreatureList lSentryList;
GetCreatureListWithEntryInGrid(lSentryList, pCreature, NPC_SENTRY, 40.0f);
for (CreatureList::const_iterator itr = lSentryList.begin(); itr != lSentryList.end(); ++itr)
{
if ((*itr)->isAlive())
{
(*itr)->SetFactionTemporary(FACTION_HOSTILE, TEMPFACTION_RESTORE_COMBAT_STOP | TEMPFACTION_RESTORE_RESPAWN);
(*itr)->AI()->AttackStart(pPlayer);
}
}
}
return true;
}
示例14: 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 (const auto& player : players)
{
if (Player* pPlayer = player.getSource())
pPlayer->CastSpell(pPlayer, SPELL_GAME_IN_SESSION, TRIGGERED_OLD_TRIGGERED);
}
m_uiAllianceStalkerCount = 0;
m_uiHordeStalkerCount = 0;
m_vHordeStalkers.clear();
m_vAllianceStalkers.clear();
// sort stalkers depending on side
CreatureList 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 (CreatureList::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 (CreatureList::const_iterator itr = lStalkers.begin(); itr != lStalkers.end(); ++itr)
m_vAllianceStalkers.push_back((*itr)->GetObjectGuid());
}
示例15: UpdateAI
void UpdateAI(const uint32 uiDiff) override
{
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
// Demoralizing Shout Timer
if (m_uiDemoralizingShoutTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_DEMORALIZING_SHOUT) == CAST_OK)
m_uiDemoralizingShoutTimer = urand(15000, 20000);
}
else
m_uiDemoralizingShoutTimer -= uiDiff;
// Inspire Timer
if (m_uiInspireTimer < uiDiff)
{
Creature* pTarget = nullptr;
CreatureList pList = DoFindFriendlyMissingBuff(45.0f, SPELL_INSPIRE);
if (!pList.empty())
{
CreatureList::iterator i = pList.begin();
advance(i, (rand() % pList.size()));
pTarget = (*i);
}
if (!pTarget)
pTarget = m_creature;
if (DoCastSpellIfCan(pTarget, SPELL_INSPIRE) == CAST_OK)
m_uiInspireTimer = 10000;
}
else
m_uiInspireTimer -= uiDiff;
// Hand of Ragnaros Timer
if (m_uiKnockdownTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_HAND_OF_RAGNAROS) == CAST_OK)
m_uiKnockdownTimer = urand(12000, 15000);
}
else
m_uiKnockdownTimer -= uiDiff;
// Flamespear Timer
if (m_uiFlamespearTimer < uiDiff)
{
if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
{
if (DoCastSpellIfCan(pTarget, SPELL_FLAMESPEAR) == CAST_OK)
m_uiFlamespearTimer = urand(12000, 16000);
}
}
else
m_uiFlamespearTimer -= uiDiff;
// Dark Strike Timer
if (m_uiDarkstrikeTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_DARK_STRIKE) == CAST_OK)
m_uiDarkstrikeTimer = urand(15000, 18000);
}
else
m_uiDarkstrikeTimer -= uiDiff;
DoMeleeAttackIfReady();
}