本文整理汇总了C++中CGroup::addBadTarget方法的典型用法代码示例。如果您正苦于以下问题:C++ CGroup::addBadTarget方法的具体用法?C++ CGroup::addBadTarget怎么用?C++ CGroup::addBadTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGroup
的用法示例。
在下文中一共展示了CGroup::addBadTarget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
//.........这里部分代码省略.........
// scan for better target among existing targets...
tf.excludeId = NULL;
int assistTarget = group->selectTarget(occupied, tf);
if (assistTarget >= 0 && assistTarget != target) {
ATask *task = ai->tasks->getTaskByTarget(assistTarget);
if (task) {
bool canAssist = false;
int assisters = task->assisters.size();
float cumulativeStrength = task->firstGroup()->strength;
std::list<ATask*>::iterator itATask;
for (itATask = task->assisters.begin(); itATask != task->assisters.end(); itATask++) {
cumulativeStrength += (*itATask)->firstGroup()->strength;
}
switch(behaviour) {
case SCOUT:
canAssist = assisters == 0;
break;
case ENGAGE:
canAssist = cumulativeStrength < 2.0f * tf.threatValue;
break;
case BOMBER:
canAssist = assisters < 9;
break;
case AIRFIGHTER:
canAssist = assisters < 3;
break;
}
if (canAssist) {
mergeGroups.erase(group->key);
if (!ai->tasks->addTask(new AssistTask(ai, *task, *group)))
group->addBadTarget(assistTarget);
break;
}
}
}
}
bool isStrongEnough = true;
if (target >= 0) {
isStrongEnough = group->strength >= (tf.threatValue - EPS);
bool isSizeEnough = (behaviour == ENGAGE) ? group->units.size() >= ai->cfgparser->getMinGroupSize(group->techlvl) : true;
if (behaviour != ENGAGE)
isAssembling = false;
if ((isAssembling && isSizeEnough) || (!isAssembling && isStrongEnough)) {
ATask::NPriority taskPriority = (behaviour == BOMBER || behaviour == AIRFIGHTER) ? ATask::HIGH : ATask::NORMAL;
mergeGroups.erase(group->key);
if (ai->tasks->addTask(new AttackTask(ai, target, *group), taskPriority)) {
occupied.push_back(target);
isOccupied[target] = true;
}
else {
group->addBadTarget(target);
}
break;
}
}
bool bMerge = !(isStrongEnough || isAssembling);
switch(behaviour) {