本文整理汇总了C++中CreatureList::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ CreatureList::empty方法的具体用法?C++ CreatureList::empty怎么用?C++ CreatureList::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CreatureList
的用法示例。
在下文中一共展示了CreatureList::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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();
}
示例4: 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);
}
示例5: 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();
}
}
示例6: GetCreature
Creature* GetCreature(uint32 uiCreatureEntry)
{
if (!lCreatureList.empty())
{
for (auto& itr : lCreatureList)
{
if (itr->GetEntry() == uiCreatureEntry && itr->isAlive())
return itr;
}
}
return nullptr;
}
示例7: 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;
}
示例8: DoStartAttackMe
void DoStartAttackMe()
{
if (!lCreatureList.empty())
{
for (auto& itr : lCreatureList)
{
if (itr->GetEntry() == NPC_REETHE)
continue;
if (itr->isAlive())
{
itr->setFaction(FACTION_THER_HOSTILE);
itr->AI()->AttackStart(m_creature);
}
}
}
}
示例9: GetClosestDwarfNotInCombat
Creature* instance_uldaman::GetClosestDwarfNotInCombat(Creature* pSearcher)
{
CreatureList lTemp;
for (GuidList::const_iterator itr = m_lWardens.begin(); itr != m_lWardens.end(); ++itr)
{
Creature* pTemp = instance->GetCreature(*itr);
if (pTemp && pTemp->isAlive() && !pTemp->getVictim())
lTemp.push_back(pTemp);
}
if (lTemp.empty())
return nullptr;
lTemp.sort(ObjectDistanceOrder(pSearcher));
return lTemp.front();
}
示例10: PrepareSummonPlaces
void PrepareSummonPlaces()
{
CreatureList lSummonList;
m_pInstance->GetGothSummonPointCreatures(lSummonList, true);
if (lSummonList.empty())
return;
// Trainees and Rider
uint8 index = 0;
uint8 uiTraineeCount = 3;
lSummonList.sort(ObjectDistanceOrder(m_creature));
for (auto& itr : lSummonList)
{
if (itr)
{
if (uiTraineeCount == 0)
break;
if (index == 1)
m_lRiderSummonPosGuids.push_back(itr->GetObjectGuid());
else
{
m_lTraineeSummonPosGuids.push_back(itr->GetObjectGuid());
--uiTraineeCount;
}
index++;
}
}
// DeathKnights
uint8 uiDeathKnightCount = 2;
lSummonList.sort(ObjectDistanceOrderReversed(m_creature));
for (auto& itr : lSummonList)
{
if (itr)
{
if (uiDeathKnightCount == 0)
break;
m_lDeathKnightSummonPosGuids.push_back(itr->GetObjectGuid());
--uiDeathKnightCount;
}
}
}
示例11: 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());
}
示例12: UpdateAI
void UpdateAI(const uint32 uiDiff) override
{
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
switch (m_uiPhase)
{
case PHASE_FAKE_DEATH:
if (m_uiResurrectTimer < uiDiff)
{
if (!m_pInstance)
return;
if (m_pInstance->GetData(TYPE_THEKAL) != SPECIAL || m_pInstance->GetData(TYPE_ZATH) != SPECIAL)
{
DoCastSpellIfCan(m_creature, SPELL_RESURRECT);
m_pInstance->SetData(TYPE_LORKHAN, IN_PROGRESS);
}
m_uiPhase = PHASE_WAITING;
}
else
m_uiResurrectTimer -= uiDiff;
// no break needed here
case PHASE_WAITING:
return;
case PHASE_NORMAL:
if (m_uiDispelTimer < uiDiff)
{
CreatureList pList = DoFindFriendlyCC(30.0f);
Creature* dispelTarget = nullptr;
if (!pList.empty())
for (auto& itr : pList)
{
dispelTarget = itr;
break;
}
if (!dispelTarget && (m_creature->isInRoots() || m_creature->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_DECREASE_SPEED)))
dispelTarget = m_creature;
if (dispelTarget && (DoCastSpellIfCan(dispelTarget, SPELL_DISPEL_MAGIC) == CAST_OK))
m_uiDispelTimer = urand(15000, 20000);
}
else
m_uiDispelTimer -= uiDiff;
// Lightning_Shield_Timer
if (m_uiLightningShieldTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_LIGHTNING_SHIELD) == CAST_OK)
m_uiLightningShieldTimer = 61000;
}
else
m_uiLightningShieldTimer -= uiDiff;
// Casting Greatheal to Thekal or Zath if they are in meele range.
// TODO - why this range check?
if (m_uiGreatHealTimer < uiDiff)
{
if (m_pInstance)
{
Creature* pThekal = m_pInstance->GetSingleCreatureFromStorage(NPC_THEKAL);
Creature* pZath = m_pInstance->GetSingleCreatureFromStorage(NPC_ZATH);
switch (urand(0, 1))
{
case 0:
if (pThekal && m_creature->IsWithinDistInMap(pThekal, 3 * ATTACK_DISTANCE))
DoCastSpellIfCan(pThekal, SPELL_GREAT_HEAL);
break;
case 1:
if (pZath && m_creature->IsWithinDistInMap(pZath, 3 * ATTACK_DISTANCE))
DoCastSpellIfCan(pZath, SPELL_GREAT_HEAL);
break;
}
}
m_uiGreatHealTimer = urand(15000, 20000);
}
else
m_uiGreatHealTimer -= uiDiff;
// Disarm_Timer
if (m_uiDisarmTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_DISARM) == CAST_OK)
m_uiDisarmTimer = urand(15000, 25000);
}
else
m_uiDisarmTimer -= uiDiff;
break;
}
DoMeleeAttackIfReady();
//.........这里部分代码省略.........
示例13: 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();
}
示例14: UpdateAI
void UpdateAI(const uint32 uiDiff) override
{
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
if (m_uiHealTimer < uiDiff)
{
if (Unit* pTarget = DoSelectLowestHpFriendly(50.0f))
{
if (DoCastSpellIfCan(pTarget, SPELL_FLASH_HEAL) == CAST_OK)
m_uiHealTimer = urand(15000, 20000);
}
}
else
m_uiHealTimer -= uiDiff;
if (m_uiRenewTimer < uiDiff)
{
if (Unit* pTarget = DoSelectLowestHpFriendly(50.0f))
{
if (DoCastSpellIfCan(pTarget, m_bIsRegularMode ? SPELL_RENEW : SPELL_RENEW_H) == CAST_OK)
m_uiRenewTimer = urand(5000, 10000);
}
}
else
m_uiRenewTimer -= uiDiff;
if (m_uiShieldTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_SHIELD : SPELL_SHIELD_H) == CAST_OK)
m_uiShieldTimer = urand(30000, 35000);
}
else
m_uiShieldTimer -= uiDiff;
if (m_uiDispelTimer < uiDiff)
{
Unit* pTarget = nullptr;
CreatureList lTempList = DoFindFriendlyCC(50.0f);
if (!lTempList.empty())
pTarget = *(lTempList.begin());
else
pTarget = DoSelectLowestHpFriendly(50.0f);
if (pTarget)
{
if (DoCastSpellIfCan(pTarget, SPELL_DISPEL_MAGIC) == CAST_OK)
m_uiDispelTimer = urand(12000, 15000);
}
}
else
m_uiDispelTimer -= uiDiff;
// Use the Medallion if CC - only on heroic. Not sure how many times they are allowed to use it.
if (!m_bIsRegularMode && m_uiMedallionTimer)
{
if (m_creature->isFrozen() || m_creature->hasUnitState(UNIT_STAT_CAN_NOT_REACT))
{
if (m_uiMedallionTimer <= uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_MEDALLION, CAST_TRIGGERED) == CAST_OK)
m_uiMedallionTimer = 0;
}
else
m_uiMedallionTimer -= uiDiff;
}
}
if (m_uiSWPainTimer < uiDiff)
{
if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, nullptr, SELECT_FLAG_PLAYER))
{
if (DoCastSpellIfCan(pTarget, m_bIsRegularMode ? SPELL_SHADOW_WORD_PAIN : SPELL_SHADOW_WORD_PAIN_H) == CAST_OK)
m_uiSWPainTimer = 10000;
}
}
else
m_uiSWPainTimer -= uiDiff;
if (m_uiScreamTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_SCREAM) == CAST_OK)
m_uiScreamTimer = urand(15000, 20000);
}
else
m_uiScreamTimer -= uiDiff;
DoMeleeAttackIfReady();
}
示例15: UpdateCompanionAI
bool UpdateCompanionAI(const uint32 uiDiff)
{
if (m_uiGoblinDragonGunTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_GOBLIN_DRAGON_GUN : SPELL_GOBLIN_DRAGON_GUN_H) == CAST_OK)
m_uiGoblinDragonGunTimer = urand(10000, 20000);
}
else
m_uiGoblinDragonGunTimer -= uiDiff;
if (m_uiRocketLaunchTimer < uiDiff)
{
if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, nullptr, SELECT_FLAG_PLAYER))
{
if (DoCastSpellIfCan(pTarget, m_bIsRegularMode ? SPELL_ROCKET_LAUNCH : SPELL_ROCKET_LAUNCH_H) == CAST_OK)
m_uiRocketLaunchTimer = 9000;
}
}
else
m_uiRocketLaunchTimer -= uiDiff;
if (m_uiFelIronBombTimer < uiDiff)
{
if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, nullptr, SELECT_FLAG_PLAYER))
{
if (DoCastSpellIfCan(pTarget, m_bIsRegularMode ? SPELL_FEL_IRON_BOMB : SPELL_FEL_IRON_BOMB_H) == CAST_OK)
m_uiFelIronBombTimer = 15000;
}
}
else
m_uiFelIronBombTimer -= uiDiff;
if (m_uiRecombobulateTimer < uiDiff)
{
// Note: this should be casted only on Polyformed targets
Unit* pTarget = nullptr;
CreatureList lTempList = DoFindFriendlyCC(50.0f);
if (!lTempList.empty())
pTarget = *(lTempList.begin());
else
pTarget = DoSelectLowestHpFriendly(50.0f);
if (pTarget)
{
if (DoCastSpellIfCan(pTarget, SPELL_RECOMBOBULATE) == CAST_OK)
m_uiRecombobulateTimer = 2000;
}
}
else
m_uiRecombobulateTimer -= uiDiff;
if (m_uiHighExplosiveSheepTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_HIGH_EXPLOSIVE_SHEEP) == CAST_OK)
m_uiHighExplosiveSheepTimer = 65000;
}
else
m_uiHighExplosiveSheepTimer -= uiDiff;
return true;
}