本文整理汇总了C++中Enemy::canUseSpecialAttack方法的典型用法代码示例。如果您正苦于以下问题:C++ Enemy::canUseSpecialAttack方法的具体用法?C++ Enemy::canUseSpecialAttack怎么用?C++ Enemy::canUseSpecialAttack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy::canUseSpecialAttack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void EnemyStartTurnState::Update(double dt)
{
// Pause state update for a duration
if (m_stateTimer < S_MAX_STATE_TIME)
{
m_stateTimer += dt;
return;
}
else
{
m_stateTimer = 0.f;
}
FSMState::Update(dt);
// Get the actual NPC-type pointer
Enemy* c = dynamic_cast<Enemy*>(m_FSMOwner);
// Check if the NPC is legit
if (!c)
{
return;
}
// If we are biding, continue biding instead of choosing another move
if (c->m_currentBideTurns > 0)
{
changeState(new EnemySpecialState());
}
else
{
// Probabilities
short attProb = c->m_attackProbability;
short stunProb = c->m_stunProbability;
short specProb = c->m_specialProbability;
// Random
short maxRand = attProb + stunProb + specProb;
short random = Math::RandIntMinMax(0, maxRand);
// Find out which action is chosen
if (random <= stunProb)
{
changeState(new StunAttackState());
}
else
{
if (random <= specProb && c->canUseSpecialAttack())
{
changeState(new EnemySpecialState());
}
else
{
changeState(new AttackState());
}
}
}
}