Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
ParatroopaAI.inc.c
Go to the documentation of this file.
1#include "common.h"
2
3// prerequisites
5
6// ai-specific states
13
15 Enemy* enemy = script->owner1.enemy;
16 Npc* npc = get_npc_unsafe(enemy->npcID);
18
19 npc->curAnim = enemy->animList[9];
20 npc->jumpVel = -5.0f;
21 npc->jumpScale = 0.15f;
22 npc->collisionHeight = enemy->varTable[8] / 2;
23
25 npc->moveSpeed = 7.0f;
26 enemy->unk_10.x = npc->pos.x;
27 enemy->unk_10.y = npc->pos.y;
28 enemy->unk_10.z = npc->pos.z;
29 enemy->hitboxIsActive = true;
30
33 npc->duration = 12;
34 npc->yaw = yawTemp;
35 script->AI_TEMP_STATE = AI_STATE_PARATROOPA_DIVE;
36}
37
39 Enemy* enemy = script->owner1.enemy;
40 Npc* npc = get_npc_unsafe(script->owner1.enemy->npcID);
41
42 npc->jumpVel += npc->jumpScale;
43 npc->pos.y += npc->jumpVel;
44 npc_move_heading(npc, npc->moveSpeed, npc->yaw);
45 npc->duration--;
46
47 if (npc->duration <= 0) {
48 enemy->hitboxIsActive = false;
49 npc->jumpScale = 0.3f;
50 npc->jumpVel = 0.0f;
51 npc->moveSpeed = 3.0f;
52 npc->curAnim = enemy->animList[10];
54 }
55}
56
58{
59 Enemy* enemy = script->owner1.enemy;
60 Npc* npc = get_npc_unsafe(enemy->npcID);
61 f32 overshootAmtRaw = enemy->varTable[3];
62 f32 posX, posY, posZ, hitDepth;
65
66 npc->jumpVel += npc->jumpScale;
67 npc->pos.y += npc->jumpVel;
69 npc_move_heading(npc, npc->moveSpeed, npc->yaw);
70
71 posX = npc->pos.x;
72 posY = npc->pos.y;
73 posZ = npc->pos.z;
74 hitDepth = 1000.0f;
75 if (npc_raycast_down_sides(npc->collisionChannel, &posX, &posY, &posZ, &hitDepth)) {
77 } else {
79 }
80
81 if (!(npc->pos.y < endOvershootHeight)) {
82 npc->duration = 10;
83 npc->curAnim = enemy->animList[11];
84 npc->collisionHeight = enemy->varTable[8];
85 script->AI_TEMP_STATE = AI_STATE_PARATROOPA_RESET;
86 }
87}
88
90 Npc* npc = get_npc_unsafe(script->owner1.enemy->npcID);
91
92 npc->duration--;
93 if (npc->duration <= 0) {
94 script->AI_TEMP_STATE = AI_STATE_WANDER_INIT;
95 }
96}
97
98API_CALLABLE(N(ParatroopaAI_Main)) {
99 Bytecode* args = script->ptrReadPos;
100 Enemy* enemy = script->owner1.enemy;
101 Npc* npc = get_npc_unsafe(enemy->npcID);
102 EnemyDetectVolume territory;
103 EnemyDetectVolume* territoryPtr = &territory;
105
106 territory.skipPlayerDetectChance = 0;
107 territory.shape = enemy->territory->wander.detectShape;
108 territory.pointX = enemy->territory->wander.detectPos.x;
109 territory.pointZ = enemy->territory->wander.detectPos.z;
110 territory.sizeX = enemy->territory->wander.detectSize.x;
111 territory.sizeZ = enemy->territory->wander.detectSize.z;
112 territory.halfHeight = 120.0f;
113 territory.detectFlags = 0;
114
115 if (isInitialCall) {
116 N(FlyingAI_Init)(npc, enemy, script, aiSettings);
117 enemy->varTable[8] = npc->collisionHeight;
118 script->AI_TEMP_STATE = 0;
119 }
120
121 npc->verticalRenderOffset = -3;
122
123 if (enemy->aiFlags & AI_FLAG_SUSPEND) {
124 if (enemy->aiSuspendTime != 0) {
125 return ApiStatus_BLOCK;
126 }
127 enemy->aiFlags &= ~AI_FLAG_SUSPEND;
128 }
129
130 switch (script->AI_TEMP_STATE) {
133 // fallthrough
134 case AI_STATE_WANDER:
136 if (script->AI_TEMP_STATE != 2) {
137 break;
138 }
139 // fallthrough
142 // fallthrough
143 case AI_STATE_LOITER:
145 if (script->AI_TEMP_STATE != AI_STATE_ALERT_INIT) {
146 break;
147 }
148 // fallthrough
151 if (script->AI_TEMP_STATE != AI_STATE_ALERT) {
152 break;
153 }
154 // fallthrough
155 case AI_STATE_ALERT:
157 if (script->AI_TEMP_STATE != AI_STATE_PARATROOPA_WINDUP) {
158 break;
159 }
160 // fallthrough
163 if (script->AI_TEMP_STATE != AI_STATE_PARATROOPA_DIVE) {
164 break;
165 }
166 // fallthrough
169 if (script->AI_TEMP_STATE != AI_STATE_PARATROOPA_OVERSHOOT) {
170 break;
171 }
172 // fallthrough
175 if (script->AI_TEMP_STATE != AI_STATE_PARATROOPA_RESET) {
176 break;
177 }
178 // fallthrough
181 break;
182 }
183 return ApiStatus_BLOCK;
184}
BSS s32 PopupMenu_SelectedIndex
void N FlyingAI_LoiterInit(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N FlyingAI_Loiter(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N FlyingAI_Jump(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N FlyingAI_Wander(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N FlyingAI_JumpInit(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N FlyingAI_Init(Npc *npc, Enemy *enemy, Evt *script, MobileAISettings *aiSettings)
void N FlyingAI_WanderInit(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N ParatroopaAI_Overshoot(Evt *script, MobileAISettings *arg1, EnemyDetectVolume *arg2)
void N ParatroopaAI_Dive(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N ParatroopaAI_Windup(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N ParatroopaAI_Reset(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
AiStateParatroopa
@ AI_STATE_PARATROOPA_DIVE
@ AI_STATE_PARATROOPA_WINDUP
@ AI_STATE_PARATROOPA_RESET
@ AI_STATE_PARATROOPA_OVERSHOOT
#define npc_raycast_down_sides
#define atan2
@ AI_FLAG_SUSPEND
Definition enums.h:4156
@ AI_STATE_WANDER
Definition enums.h:4167
@ AI_STATE_LOITER
Definition enums.h:4173
@ AI_STATE_WANDER_INIT
Definition enums.h:4166
@ AI_STATE_LOITER_INIT
Definition enums.h:4172
@ AI_STATE_ALERT
Definition enums.h:4176
@ AI_STATE_ALERT_INIT
Definition enums.h:4175
@ SOUND_PARAGOOMBA_DIVE
Definition enums.h:1032
s32 Bytecode
Definition evt.h:7
#define ApiStatus_BLOCK
Definition evt.h:117
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1730
void ai_enemy_play_sound(Npc *npc, s32 arg1, s32 arg2)
Definition 23680.c:543
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
enum TerritoryShape shape
Definition npc.h:201
VecXZi detectSize
Definition npc.h:216
enum TerritoryShape detectShape
Definition npc.h:217
s16 npcID
Definition npc.h:300
s32 * animList
Definition npc.h:341
s8 aiSuspendTime
Definition npc.h:333
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:992
Vec3s unk_10
Definition npc.h:302
s8 hitboxIsActive
Definition npc.h:299
s16 detectFlags
Definition npc.h:207
u32 aiFlags
Definition npc.h:332
void npc_move_heading(Npc *npc, f32 speed, f32 yaw)
Definition npc.c:983
s32 skipPlayerDetectChance
Definition npc.h:200
EnemyTerritoryWander wander
Definition npc.h:232
EnemyTerritory * territory
Definition npc.h:342
Definition npc.h:294
f32 jumpScale
f32 jumpVel
AnimID curAnim
s32 collisionChannel
s16 collisionHeight
s8 verticalRenderOffset
Vec3f pos
f32 moveSpeed
s16 duration
PlayerStatus * gPlayerStatusPtr