本文整理汇总了C++中CvUnit::AI_follow方法的典型用法代码示例。如果您正苦于以下问题:C++ CvUnit::AI_follow方法的具体用法?C++ CvUnit::AI_follow怎么用?C++ CvUnit::AI_follow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvUnit
的用法示例。
在下文中一共展示了CvUnit::AI_follow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AI_update
//.........这里部分代码省略.........
gDLL->messageControlLog(szOut);
}
pHeadUnit->finishMoves();
}
break;
}
// if we want to force the group to attack, force another attack
if (m_bGroupAttack)
{
m_bGroupAttack = false;
groupAttack(m_iGroupAttackX, m_iGroupAttackY, MOVE_DIRECT_ATTACK, bFailedAlreadyFighting);
}
// else pick AI action
else
{
CvUnit* pHeadUnit = getHeadUnit();
if (pHeadUnit == NULL || pHeadUnit->isDelayedDeath())
{
break;
}
resetPath();
if (pHeadUnit->AI_update())
{
// AI_update returns true when we should abort the loop and wait until next slice
break;
}
}
if (doDelayedDeath())
{
bDead = true;
break;
}
// if no longer group attacking, and force separate is true, then bail, decide what to do after group is split up
// (UnitAI of head unit may have changed)
if (!m_bGroupAttack && AI_isForceSeparate())
{
AI_separate(); // pointers could become invalid...
return true;
}
}
if (!bDead)
{
if (!isHuman())
{
bFollow = false;
// if we not group attacking, then check for follow action
if (!m_bGroupAttack)
{
pEntityNode = headUnitNode();
while ((pEntityNode != NULL) && readyToMove(true))
{
pLoopUnit = ::getUnit(pEntityNode->m_data);
pEntityNode = nextUnitNode(pEntityNode);
if (pLoopUnit->canMove())
{
resetPath();
if (pLoopUnit->AI_follow())
{
bFollow = true;
break;
}
}
}
}
if (doDelayedDeath())
{
bDead = true;
}
if (!bDead)
{
if (!bFollow && readyToMove(true))
{
pushMission(MISSION_SKIP);
}
}
}
}
if (bDead)
{
return true;
}
return (isBusy() || isCargoBusy());
}
示例2: AI_update
//.........这里部分代码省略.........
//if (pHeadUnit == NULL || pHeadUnit->isDelayedDeath())
if (pHeadUnit == NULL || pHeadUnit->doDelayedDeath()) // K-Mod
{
break;
}
//resetPath();
if (pHeadUnit->AI_update())
{
// AI_update returns true when we should abort the loop and wait until next slice
FAssert(!pHeadUnit->isDelayedDeath());
break;
}
}
if (doDelayedDeath())
{
bDead = true;
break;
}
// if no longer group attacking, and force separate is true, then bail, decide what to do after group is split up
// (UnitAI of head unit may have changed)
if (!AI_isGroupAttack() && AI_isForceSeparate())
{
AI_separate(); // pointers could become invalid...
//return true;
return false; // K-Mod
}
}
if (!bDead)
{
if (!isHuman())
{
bFollow = false;
// if we not group attacking, then check for follow action
if (!AI_isGroupAttack())
{
pEntityNode = headUnitNode();
// K-Mod note: I've rearranged a few things below, and added 'bFirst'.
bool bFirst = true;
while ((pEntityNode != NULL) && readyToMove(true))
{
pLoopUnit = ::getUnit(pEntityNode->m_data);
pEntityNode = nextUnitNode(pEntityNode);
if (bFirst)
resetPath();
if (pLoopUnit->canMove())
{
if (pLoopUnit->AI_follow(bFirst))
{
bFollow = true;
bFirst = true; // let the next unit start fresh.
}
else
bFirst = false;
}
}
// K-Mod end
}
if (doDelayedDeath())
{
bDead = true;
}
if (!bDead)
{
if (!bFollow && readyToMove(true))
{
pushMission(MISSION_SKIP);
}
}
/************************************************************************************************/
/* BETTER_BTS_AI_MOD 04/28/10 jdog5000 */
/* */
/* Unit AI */
/************************************************************************************************/
// AI should never put units to sleep, how does this ever happen?
//FAssert( getHeadUnit()->isCargo() || getActivityType() != ACTIVITY_SLEEP );
/************************************************************************************************/
/* BETTER_BTS_AI_MOD END */
/************************************************************************************************/
}
}
if (bDead)
{
//return true;
return false; // K-Mod
}
return (isBusy() || isCargoBusy());
}