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()); } } } }