本文整理汇总了C++中UnitPointer::isAlive方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitPointer::isAlive方法的具体用法?C++ UnitPointer::isAlive怎么用?C++ UnitPointer::isAlive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitPointer
的用法示例。
在下文中一共展示了UnitPointer::isAlive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CastSpellOnRandomTarget
void CastSpellOnRandomTarget(uint32 i, float mindist2cast, float maxdist2cast, int minhp2cast, int maxhp2cast)
{
if (!maxdist2cast) maxdist2cast = 100.0f;
if (!maxhp2cast) maxhp2cast = 100;
if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget())
{
std::vector<UnitPointer> TargetTable; /* From M4ksiu - Big THX to Capt who helped me with std stuff to make it simple and fully working <3 */
/* If anyone wants to use this function, then leave this note! */
for(unordered_set<ObjectPointer>::iterator itr = _unit->GetInRangeSetBegin(); itr != _unit->GetInRangeSetEnd(); ++itr)
{
if (((spells[i].targettype == TARGET_RANDOM_FRIEND && isFriendly(_unit, (*itr))) || (spells[i].targettype != TARGET_RANDOM_FRIEND && isHostile(_unit, (*itr)) && (*itr) != _unit)) && ((*itr)->GetTypeId()== TYPEID_UNIT || (*itr)->GetTypeId() == TYPEID_PLAYER) && (*itr)->GetInstanceID() == _unit->GetInstanceID()) // isAttackable(_unit, (*itr)) &&
{
UnitPointer RandomTarget = NULLUNIT;
RandomTarget = TO_UNIT(*itr);
if (RandomTarget->isAlive() && _unit->GetDistance2dSq(RandomTarget) >= mindist2cast*mindist2cast && _unit->GetDistance2dSq(RandomTarget) <= maxdist2cast*maxdist2cast && ((RandomTarget->GetHealthPct() >= minhp2cast && RandomTarget->GetHealthPct() <= maxhp2cast && spells[i].targettype == TARGET_RANDOM_FRIEND) || (_unit->GetAIInterface()->getThreatByPtr(RandomTarget) > 0 && isHostile(_unit, RandomTarget))))
{
TargetTable.push_back(RandomTarget);
}
}
}
if (_unit->GetHealthPct() >= minhp2cast && _unit->GetHealthPct() <= maxhp2cast && spells[i].targettype == TARGET_RANDOM_FRIEND)
TargetTable.push_back(_unit);
if (!TargetTable.size())
return;
size_t RandTarget = rand()%TargetTable.size();
UnitPointer RTarget = TargetTable[RandTarget];
if (!RTarget)
return;
switch (spells[i].targettype)
{
case TARGET_RANDOM_FRIEND:
case TARGET_RANDOM_SINGLE:
_unit->CastSpell(RTarget, spells[i].info, spells[i].instant); break;
case TARGET_RANDOM_DESTINATION:
_unit->CastSpellAoF(RTarget->GetPositionX(), RTarget->GetPositionY(), RTarget->GetPositionZ(), spells[i].info, spells[i].instant); break;
}
TargetTable.clear();
}
}
示例2: OnCombatStart
void OnCombatStart(UnitPointer mTarget)
{
_unit->GetAIInterface()->m_canMove = false;
_unit->GetAIInterface()->disable_melee = true;
_unit->SetUInt64Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
UnitPointer antusul = NULLUNIT;
antusul = _unit->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(1815.030029f, 686.817017f, 14.519000f, 8127);
if(antusul)
{
if(antusul->isAlive())
{
antusul->GetAIInterface()->AttackReaction(mTarget, 0, 0);
antusul->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Lunch has arrived, my beutiful childern. Tear them to pieces!");
}
}
}
示例3: OnEmote
void OnEmote(PlayerPointer pPlayer, uint32 Emote, UnitPointer pUnit)
{
pUnit = pPlayer->GetMapMgr()->GetUnit(pPlayer->GetSelection());
if (!pUnit || !pUnit->isAlive() || pUnit->GetAIInterface()->GetNextTarget())
return;
// Switch For Emote Name (You do EmoteName to Script Name link).
switch(Emote)
{
case EMOTE_ONESHOT_SALUTE: // <- Its EMOTE name.
GuardsOnSalute(pPlayer, pUnit); // <- Its Link.
break;
case EMOTE_ONESHOT_KISS:
GaurdsOnKiss(pPlayer, pUnit);
break;
case EMOTE_ONESHOT_WAVE:
GuardsOnWave(pPlayer, pUnit);
break;
}
}