55#include " AIProbability.hpp"
66#include " AIControl.hpp"
77#include " kart/KartState.hpp"
8+ #include < rk_common.h>
89
910namespace Enemy {
1011
@@ -22,9 +23,13 @@ void AITrickHandler::avoidPow() {
2223 mpInfo->mpInput ->setTrick (System::KPadRaceInputState::UP_TRICK);
2324}
2425
25- bool AITrickHandler::isStartingAirborne () {
26+ bool AITrickHandler::allowTricking () {
2627 Kart::KartState* state = mpInfo->mpAI ->kartState ();
2728
29+ /* *
30+ * Ensure that CPUs can only request tricking when they are in the air and
31+ * not when they're on a jump pad or mushroom trampoline, or while hit with an object.
32+ */
2833 if (state->on (Kart::KART_FLAG_AIR_START) && !state->on (Kart::KART_FLAG_JUMPPAD) && !state->on (Kart::KART_FLAG_HIT_ITEM_OR_OBJ)) {
2934 return true ;
3035 }
@@ -35,7 +40,7 @@ bool AITrickHandler::isStartingAirborne() {
3540bool AITrickHandler::shouldTrick () {
3641 AIProbabilityBase* probability = mpInfo->mpAI ->mpEngine ->mpControl ->getAIProbability ();
3742
38- if (isStartingAirborne () && probability->getTrick ()) {
43+ if (allowTricking () && probability->getTrick ()) {
3944 return true ;
4045 }
4146
@@ -58,12 +63,12 @@ void AITrickHandler::update() {
5863 if (shouldTrick ()) {
5964 System::KPadRaceInputState* input = mpInfo->mpInput ;
6065
61- const int kartTricks[2 ] = {
66+ const System::KPadRaceInputState::eTrick kartTricks[2 ] = {
6267 System::KPadRaceInputState::UP_TRICK,
6368 System::KPadRaceInputState::DOWN_TRICK
6469 };
6570
66- int rand = AIManager::getInstance ()->getRandU32 (ARRAY_COUNT (kartTricks));
71+ u32 rand = AIManager::getInstance ()->getRandU32 (ARRAY_COUNT (kartTricks));
6772 input->setTrick (kartTricks[rand]);
6873 }
6974}
@@ -99,11 +104,11 @@ void AITrickHandlerBike::calcWheelie() {
99104
100105 System::KPadRaceInputState* input = mpInfo->mpInput ;
101106
102- if (pathHandler->field_0x0C ->shouldWheelie () && probability->getWheelie () && !disableWheelie) {
107+ if (pathHandler->mpCurrPointParam ->shouldWheelie () && probability->getWheelie () && !disableWheelie) {
103108 mbPerformWheelie = true ;
104109 }
105110
106- if (pathHandler->field_0x0C ->shouldEndWheelie ()) {
111+ if (pathHandler->mpCurrPointParam ->shouldEndWheelie ()) {
107112 mbPerformWheelie = false ;
108113 input->setTrick (System::KPadRaceInputState::DOWN_TRICK);
109114 }
@@ -118,14 +123,14 @@ void AITrickHandlerBike::update() {
118123 if (shouldTrick ()) {
119124 System::KPadRaceInputState* input = mpInfo->mpInput ;
120125
121- const int bikeTricks[4 ] = {
126+ const System::KPadRaceInputState::eTrick bikeTricks[4 ] = {
122127 System::KPadRaceInputState::UP_TRICK,
123128 System::KPadRaceInputState::DOWN_TRICK,
124129 System::KPadRaceInputState::LEFT_TRICK,
125130 System::KPadRaceInputState::RIGHT_TRICK,
126131 };
127132
128- int rand = AIManager::getInstance ()->getRandU32 (ARRAY_COUNT (bikeTricks));
133+ u32 rand = AIManager::getInstance ()->getRandU32 (ARRAY_COUNT (bikeTricks));
129134 input->setTrick (bikeTricks[rand]);
130135 }
131136}
0 commit comments