本文整理汇总了C++中BattleItem::setExplodeTurn方法的典型用法代码示例。如果您正苦于以下问题:C++ BattleItem::setExplodeTurn方法的具体用法?C++ BattleItem::setExplodeTurn怎么用?C++ BattleItem::setExplodeTurn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BattleItem
的用法示例。
在下文中一共展示了BattleItem::setExplodeTurn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: think
//.........这里部分代码省略.........
return;
}
takeCover = true; // always seek cover as last action (unless melee... charge, stupid reapers!)
action->reckless = true;
}
if (!takeCover && !charge)
{
_timesNotSeen = 0;
_lastKnownPosition = _aggroTarget->getPosition();
action->target = _aggroTarget->getPosition();
action->type = BA_NONE;
// lets' evaluate if we could throw a grenade
int tu = 4; // 4TUs for picking up the grenade
// do we have a grenade on our belt?
BattleItem *grenade = _unit->getGrenadeFromBelt();
// distance must be more than X tiles, otherwise it's too dangerous to play with explosives
if (grenade && explosiveEfficacy(_aggroTarget->getPosition(), _unit, (grenade->getRules()->getPower()/10)+1, action->diff))
{
if((_unit->getFaction() == FACTION_NEUTRAL && _aggroTarget->getFaction() == FACTION_HOSTILE) || _unit->getFaction() == FACTION_HOSTILE)
{
action->weapon = grenade;
tu += _unit->getActionTUs(BA_PRIME, grenade);
tu += _unit->getActionTUs(BA_THROW, grenade);
// do we have enough TUs to prime and throw the grenade?
if (tu <= _unit->getStats()->tu)
{
// are we within range?
if (ProjectileFlyBState::validThrowRange(action))
{
grenade->setExplodeTurn(_game->getTurn());
_unit->spendTimeUnits(_unit->getActionTUs(BA_PRIME, grenade));
action->type = BA_THROW;
}
}
}
}
if (action->type == BA_NONE)
{
action->weapon = action->actor->getMainHandWeapon();
// out of ammo or no weapon or ammo at all, we have to take cover
if (!action->weapon)
{
takeCover = true;
}
else
{
if(action->weapon->getAmmoItem() && ((_unit->getFaction() == FACTION_NEUTRAL && _aggroTarget->getFaction() == FACTION_HOSTILE) || _unit->getFaction() == FACTION_HOSTILE))
{
if (action->weapon->getAmmoItem()->getRules()->getDamageType() != DT_HE || explosiveEfficacy(_aggroTarget->getPosition(), _unit, (action->weapon->getAmmoItem()->getRules()->getPower() / 10) +1, action->diff))
{
if (RNG::generate(1,10) < 5 && action->weapon->getAmmoQuantity() > 2)
{
action->type = BA_AUTOSHOT;
}
else
{
action->type = BA_SNAPSHOT;
}
}
tu = action->actor->getActionTUs(action->type, action->weapon);
// enough time units to shoot?
示例2: think
//.........这里部分代码省略.........
_game->getPathfinding()->abortPath();
}
}
}
}
}
if (!takeCover && !charge)
{
_timesNotSeen = 0;
_lastKnownPosition = _aggroTarget->getPosition();
action->target = _aggroTarget->getPosition();
action->type = BA_NONE;
// lets' evaluate if we could throw a grenade
int tu = 4; // 4TUs for picking up the grenade
// do we have a grenade on our belt?
BattleItem *grenade = _unit->getGrenadeFromBelt();
// distance must be more than X tiles, otherwise it's too dangerous to play with explosives
if (grenade && explosiveEfficacy(_aggroTarget->getPosition(), _unit, (grenade->getRules()->getPower()/10)+1, action->diff))
{
if((_unit->getFaction() == FACTION_NEUTRAL && _aggroTarget->getFaction() == FACTION_HOSTILE) || _unit->getFaction() == FACTION_HOSTILE)
{
action->weapon = grenade;
tu += _unit->getActionTUs(BA_PRIME, grenade);
tu += _unit->getActionTUs(BA_THROW, grenade);
// do we have enough TUs to prime and throw the grenade?
if (tu <= _unit->getStats()->tu)
{
// are we within range?
if (ProjectileFlyBState::validThrowRange(action))
{
grenade->setExplodeTurn(_game->getTurn());
_unit->spendTimeUnits(_unit->getActionTUs(BA_PRIME, grenade));
action->type = BA_THROW;
}
}
}
}
if (action->type == BA_NONE)
{
action->weapon = action->actor->getMainHandWeapon();
// out of ammo or no weapon or ammo at all, we have to take cover
if (!action->weapon)
{
takeCover = true;
}
else
{
if(action->weapon->getAmmoItem() && ((_unit->getFaction() == FACTION_NEUTRAL && _aggroTarget->getFaction() == FACTION_HOSTILE) || _unit->getFaction() == FACTION_HOSTILE))
{
if (action->weapon->getAmmoItem()->getRules()->getDamageType() != DT_HE || explosiveEfficacy(_aggroTarget->getPosition(), _unit, (action->weapon->getAmmoItem()->getRules()->getPower() / 10) +1, action->diff))
{
if (RNG::generate(1,10) < 5 && action->weapon->getAmmoQuantity() > 2)
{
action->type = BA_AUTOSHOT;
}
else
{
action->type = BA_SNAPSHOT;
}
}
tu = action->actor->getActionTUs(action->type, action->weapon);
// enough time units to shoot?
示例3: think
/**
* Runs any code the state needs to keep updating every
* AI cycle.
* @param action (possible) AI action to execute after thinking is done.
*/
void AggroBAIState::think(BattleAction *action)
{
action->type = BA_NONE;
action->actor = _unit;
/* Aggro is mainly either shooting a target or running towards it (melee).
If we do no action here - we assume we lost aggro and will go back to patrol state.
*/
int aggression = _unit->getUnit()->getAggression();
_aggroTarget = 0;
for (std::vector<BattleUnit*>::iterator j = _unit->getVisibleUnits()->begin(); j != _unit->getVisibleUnits()->end(); ++j)
{
_aggroTarget = (*j);
}
// if we currently see no target, we either can move to it's last seen position or loose aggro
if (_aggroTarget == 0 || _aggroTarget->isOut())
{
_timesNotSeen++;
if (_timesNotSeen > _unit->getUnit()->getIntelligence() || aggression == 0)
{
// we lost aggro - going back to patrol state
return;
}
// lets go looking where we've last seen him
action->type = BA_WALK;
action->target = _lastKnownPosition;
}
else
{
// if we see the target, we either can shoot him, or take cover.
bool takeCover = true;
int number = RNG::generate(0,100);
// lost health, chances to take cover get bigger
if (_unit->getHealth() < _unit->getUnit()->getHealth())
number += 10;
if (aggression == 0 && number < 10)
takeCover = false;
if (aggression == 1 && number < 50)
takeCover = false;
if (aggression == 2 && number < 90)
takeCover = false;
if (!takeCover)
{
_timesNotSeen = 0;
_lastKnownPosition = _aggroTarget->getPosition();
action->target = _aggroTarget->getPosition();
action->type = BA_NONE;
// lets' evaluate if we could throw a grenade
int tu = 4; // 4TUs for picking up the grenade
// distance must be more than 6 tiles, otherwise it's too dangerous to play with explosives
if (_game->getTileEngine()->distance(_unit->getPosition(), _aggroTarget->getPosition()) > 6)
{
// do we have a grenade on our belt?
BattleItem *grenade = _unit->getGrenadeFromBelt();
// do we have enough TUs to prime and throw the grenade?
if (grenade)
{
action->weapon = grenade;
tu += _unit->getActionTUs(BA_PRIME, grenade);
tu += _unit->getActionTUs(BA_THROW, grenade);
if (tu <= _unit->getTimeUnits())
{
// are we within range?
if (ProjectileFlyBState::validThrowRange(action))
{
grenade->setExplodeTurn(_game->getTurn());
_unit->spendTimeUnits(_unit->getActionTUs(BA_PRIME, grenade), false);
action->type = BA_THROW;
}
}
}
}
if (action->type == BA_NONE)
{
action->weapon = action->actor->getMainHandWeapon();
// out of ammo or no weapon or ammo at all, we have to take cover
if (!action->weapon || !action->weapon->getAmmoItem() || !action->weapon->getAmmoItem()->getAmmoQuantity())
{
takeCover = true;
}
else
{
if (RNG::generate(1,10) < 5)
action->type = BA_SNAPSHOT;
else
action->type = BA_AUTOSHOT;
tu = action->actor->getActionTUs(action->type, action->weapon);
//.........这里部分代码省略.........