本文整理汇总了C++中P_NPC::attackTarget方法的典型用法代码示例。如果您正苦于以下问题:C++ P_NPC::attackTarget方法的具体用法?C++ P_NPC::attackTarget怎么用?C++ P_NPC::attackTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_NPC
的用法示例。
在下文中一共展示了P_NPC::attackTarget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findDispelOpponent
/*
Find something to dispel we are fighting.
*/
P_NPC findDispelOpponent()
{
if ( m_npc->intelligence() < 95 || m_npc->summoned() )
{
return 0; // No dispelling below 95 int or if the NPC is summoned itself.
}
QPtrList<cFightInfo> &fights = m_npc->fights();
Monster_Aggressive *ai = static_cast<Monster_Aggressive*>( m_ai );
P_NPC currentTarget = 0;
unsigned int currentPriority = 0;
/*
Check our current attack target. It has the highest priority of all since
we are fighting it anyway.
*/
if ( !invalidTarget( m_npc, ai->currentVictim() ) && canDispel( ai->currentVictim() ) )
{
currentTarget = dynamic_cast<P_NPC>( ai->currentVictim() );
currentPriority = m_npc->dist( ai->currentVictim() );
if ( currentPriority <= 2 )
{
return currentTarget; // We found a threat in our range, so dispel it now.
}
}
/*
Now check everyone who is fighting us
*/
for ( cFightInfo*info = fights.first(); info; info = fights.next() )
{
P_NPC checkTarget;
if ( info->victim() == m_npc )
{
checkTarget = dynamic_cast<P_NPC>( info->attacker() );
}
else
{
checkTarget = dynamic_cast<P_NPC>( info->victim() );
}
// They have to be fighting us or they are uninteresting for this check
if ( !checkTarget || checkTarget->attackTarget() != m_npc )
{
continue;
}
if ( !invalidTarget( m_npc, checkTarget ) && canDispel( checkTarget ) )
{
unsigned int newPriority = m_npc->dist( checkTarget );
if ( !currentTarget || currentPriority > newPriority )
{
currentTarget = dynamic_cast<P_NPC>( ai->currentVictim() );
currentPriority = m_npc->dist( ai->currentVictim() );
if ( currentPriority <= 2 )
{
return currentTarget; // We found a threat in our range, so dispel it now.
}
}
}
}
return currentTarget;
}