Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
FlyingMagikoopaAI.inc.c File Reference

Go to the source code of this file.

Enumerations

enum  MagikoopaMoveResult { RESULT_SEARCHING = 0 , RESULT_OK_BLOCKED = 1 , RESULT_OK_CLEAR = 2 , RESULT_NONE_FOUND = 3 }
 

Functions

voidFlyingMagikoopaAI_10 (Evt *script, MobileAISettings *arg1, EnemyDetectVolume *arg2)
 
voidFlyingMagikoopaAI_11 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *volume)
 
voidFlyingMagikoopaAI_15 (Evt *arg0, MobileAISettings *arg1, EnemyDetectVolume *arg2)
 
voidFlyingMagikoopaAI_16 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
voidFlyingMagikoopaAI_17 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
voidFlyingMagikoopaAI_20 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
voidFlyingMagikoopaAI_21 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
voidFlyingMagikoopaAI_22 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
voidFlyingMagikoopaAI_23 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
voidFlyingMagikoopaAI_24 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
voidFlyingMagikoopaAI_50 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 

Enumeration Type Documentation

◆ MagikoopaMoveResult

Enumerator
RESULT_SEARCHING 
RESULT_OK_BLOCKED 
RESULT_OK_CLEAR 
RESULT_NONE_FOUND 

Definition at line 37 of file FlyingMagikoopaAI.inc.c.

37 {
42};
@ RESULT_OK_BLOCKED
@ RESULT_OK_CLEAR
@ RESULT_NONE_FOUND
@ RESULT_SEARCHING

Function Documentation

◆ FlyingMagikoopaAI_10()

void N FlyingMagikoopaAI_10 ( Evt * script,
MobileAISettings * arg1,
EnemyDetectVolume * arg2 )

Definition at line 6 of file FlyingMagikoopaAI.inc.c.

6 {
7 Enemy* enemy = script->owner1.enemy;
8 Npc* npc = get_npc_unsafe(enemy->npcID);
9
10 npc->duration = 30;
11 script->AI_TEMP_STATE = 11;
12}
BSS s32 PopupMenu_SelectedIndex
s16 npcID
Definition npc.h:300
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:992
Definition npc.h:294
s16 duration

◆ FlyingMagikoopaAI_11()

void N FlyingMagikoopaAI_11 ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * volume )

Definition at line 14 of file FlyingMagikoopaAI.inc.c.

14 {
15 Enemy* enemy = script->owner1.enemy;
16 Npc* npc = get_npc_unsafe(enemy->npcID);
17 f32 basePosY = (f32)enemy->varTable[1] / 100.0;
19
20 npc->pos.y = basePosY + sin_deg(enemy->varTable[0]) * 6.0;
21 enemy->varTable[0] = clamp_angle(enemy->varTable[0] + 10);
22
23 if (N(MagikoopaAI_CanShootSpell)(script, aiSettings->chaseRadius, aiSettings->chaseOffsetDist, volume) == 1) {
24 fx_emote(0, npc, 0.0f, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 15, &emoteTemp);
26 npc->duration = 50;
27 script->AI_TEMP_STATE = 20;
28 } else {
29 npc->duration--;
30 if (npc->duration <= 0) {
31 npc->duration = 5;
32 script->AI_TEMP_STATE = 15;
33 }
34 }
35}
s32 N MagikoopaAI_CanShootSpell(Evt *script, f32 arg1, f32 arg2, EnemyDetectVolume *territory)
#define sin_deg
#define clamp_angle
@ SOUND_AI_ALERT_A
Definition enums.h:1081
@ SOUND_PARAM_MORE_QUIET
Definition enums.h:1749
void ai_enemy_play_sound(Npc *npc, s32 arg1, s32 arg2)
Definition 23680.c:543

◆ FlyingMagikoopaAI_15()

void N FlyingMagikoopaAI_15 ( Evt * arg0,
MobileAISettings * arg1,
EnemyDetectVolume * arg2 )

Definition at line 44 of file FlyingMagikoopaAI.inc.c.

44 {
48 s32 isCCW;
49 f32 moveDist;
51
52 Enemy* enemy = arg0->owner1.enemy;
53 Npc* npc = get_npc_unsafe(enemy->npcID);
54 f32 posX, posY, posZ;
55 s32 result = RESULT_SEARCHING;
56 s32 iterations = 0;
57
58 npc->duration--;
59 if (npc->duration <= 0) {
60 randomDist = rand_int(30) + 180.0;
61 isCCW = false;
63 npc->yaw = atan2(npc->pos.x, npc->pos.z, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z) - iterations;
64 moveDist = dist2D(npc->pos.x, npc->pos.z, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z);
65 if (randomDist > moveDist) {
66 randomDist = moveDist;
67 }
68 } else {
69 npc->yaw = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
70 if (npc->yaw < 180.0) {
71 baseYaw = (rand_int(10) + 90.0) - 5.0;
72 } else {
73 baseYaw = (rand_int(10) + 270.0) - 5.0;
74 }
76 while (true) {
77 if (isCCW) {
78 npc->yaw = baseYaw + angleAdjust;
79 } else {
80 npc->yaw = baseYaw - angleAdjust;
81 }
82 posX = npc->pos.x;
83 posY = npc->pos.y;
84 posZ = npc->pos.z;
85 if (npc_test_move_taller_with_slipping(0, &posX, &posY, &posZ,
87 moveDist = dist2D(npc->pos.x, npc->pos.z, posX, posZ);
88 distToHit = moveDist;
89 if (distToHit > 160.0) {
90 if (distToHit < randomDist) {
92 }
93 result = RESULT_OK_BLOCKED;
94 }
95 } else {
96 result = RESULT_OK_CLEAR;
97 }
98
99 if (result != RESULT_SEARCHING) {
100 break;
101 }
102
103 if (!isCCW) {
104 isCCW = true;
105 } else {
106 angleAdjust += 5;
107 iterations++;
108 isCCW = false;
109 }
110
111 if (iterations >= 7) {
112 result = RESULT_NONE_FOUND;
113 }
114 }
115 }
116 posX = npc->pos.x;
117 posZ = npc->pos.z;
118 add_vec2D_polar(&posX, &posZ, randomDist, npc->yaw);
119 npc->moveToPos.x = posX;
120 npc->moveToPos.y = npc->pos.y;
121 npc->moveToPos.z = posZ;
122 enemy->varTable[4] = npc->pos.x * 100.0;
123 enemy->varTable[6] = npc->pos.z * 100.0;
124 enemy->varTable[3] = rand_int(10) + 35;
125 npc->duration = 0;
126 npc->moveSpeed = 3.0f;
127 npc->jumpVel = 1.4f;
128 npc->jumpScale = 0.2f;
129 arg0->functionTemp[0] = 0x10;
130 }
131}
#define rand_int
#define atan2
b32 is_point_outside_territory(s32 shape, f32 pointX, f32 pointY, f32 centerX, f32 centerY, f32 sizeX, f32 sizeZ)
Definition 23680.c:412
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
b32 npc_test_move_taller_with_slipping(s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
void add_vec2D_polar(f32 *x, f32 *y, f32 r, f32 theta)
Definition 43F0.c:685
VecXZi wanderSize
Definition npc.h:212
enum TerritoryShape wanderShape
Definition npc.h:214
EnemyTerritoryWander wander
Definition npc.h:232
EnemyTerritory * territory
Definition npc.h:342
s16 collisionDiameter
f32 jumpScale
f32 jumpVel
Vec3f moveToPos
s16 collisionHeight
Vec3f pos
f32 moveSpeed
PlayerStatus * gPlayerStatusPtr

◆ FlyingMagikoopaAI_16()

void N FlyingMagikoopaAI_16 ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * territory )

Definition at line 133 of file FlyingMagikoopaAI.inc.c.

133 {
134 Enemy* enemy = script->owner1.enemy;
135 Npc* npc = get_npc_unsafe(enemy->npcID);
136 f32 basePosY = (f32)enemy->varTable[1] / 100.0;
137
138 enemy->varTable[0] = clamp_angle(enemy->varTable[0] + 10);
139 npc->pos.y = basePosY + sin_deg(enemy->varTable[0]) * 6.0;
140
141 if (npc->turnAroundYawAdjustment == 0) {
142 enemy->varTable[5] = npc->pos.y * 100.0;
143 script->functionTemp[0] = 17;
144 }
145}

◆ FlyingMagikoopaAI_17()

void N FlyingMagikoopaAI_17 ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * territory )

Definition at line 147 of file FlyingMagikoopaAI.inc.c.

147 {
148 Enemy* enemy = script->owner1.enemy;
149 Npc* npc = get_npc_unsafe(enemy->npcID);
150 f32 limitY = (f32)enemy->varTable[1] / 100.0;
151 f32 basePosY = (f32)enemy->varTable[5] / 100.0;
152 f32 startX = (f32)enemy->varTable[4] / 100.0;
153 f32 startZ = (f32)enemy->varTable[6] / 100.0;
154 f32 lerpX = update_lerp(EASING_SIN_OUT, startX, npc->moveToPos.x, npc->duration, enemy->varTable[3]);
155 f32 lerpZ = update_lerp(EASING_SIN_OUT, startZ, npc->moveToPos.z, npc->duration, enemy->varTable[3]);
156
157 npc->pos.x = lerpX;
158 npc->pos.z = lerpZ;
159 npc->pos.y = basePosY + sin_deg((s32)(npc->duration * (180.0 / (f32)enemy->varTable[3])) + 180) * 25.0;
160
161 npc->duration++;
162 if (npc->duration == (enemy->varTable[3] - 8)) {
163 npc->yaw = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
164 }
165 if (limitY <= npc->pos.y) {
166 npc->pos.y = limitY;
167 enemy->varTable[0] = 0;
168 script->functionTemp[0] = 10;
169 } else if (npc->duration >= enemy->varTable[3]) {
170 if (enemy->varTable[0] >= 180.0) {
171 if (enemy->varTable[0] < 270.0) {
172 enemy->varTable[0] = clamp_angle(540 - enemy->varTable[0]);
173 }
174 }
175 script->functionTemp[0] = 10;
176 }
177}
Vec3s pos
Definition demo_api.c:17
@ EASING_SIN_OUT
Definition enums.h:521
f32 update_lerp(s32 easing, f32 start, f32 end, s32 elapsed, s32 duration)
Definition 43F0.c:735

◆ FlyingMagikoopaAI_20()

void N FlyingMagikoopaAI_20 ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * territory )

Definition at line 179 of file FlyingMagikoopaAI.inc.c.

179 {
180 Enemy* enemy = script->owner1.enemy;
181 Npc* npc = get_npc_unsafe(enemy->npcID);
182
183 npc->duration = 40;
184 script->functionTemp[0] = 21;
185}

◆ FlyingMagikoopaAI_21()

void N FlyingMagikoopaAI_21 ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * territory )

Definition at line 187 of file FlyingMagikoopaAI.inc.c.

187 {
188 Enemy* enemy = script->owner1.enemy;
189 Npc* npc = get_npc_unsafe(enemy->npcID);
190 f32 posX, posY, posZ;
192
193 npc->duration--;
194 if (npc->duration == 0) {
195 npc->curAnim = enemy->animList[0];
196 fx_emote(2, npc, 0.0f, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 12, &emoteTemp);
197 npc->curAnim = enemy->animList[0];
198 npc->duration = 15;
199 script->functionTemp[0] = 50;
200 } else if ((N(MagikoopaAI_CanShootSpell)(script, aiSettings->chaseRadius, aiSettings->chaseOffsetDist, territory) == 1) && (npc->turnAroundYawAdjustment == 0)) {
201 ai_enemy_play_sound(npc, 0x20D4, 0);
202 npc->curAnim = enemy->animList[8];
203 posX = npc->pos.x;
204 posY = npc->pos.y + 29.0f;
205 posZ = npc->pos.z + 1.0f;
206 add_vec2D_polar(&posX, &posZ, 30.0f, 270.0f - npc->renderYaw);
207 fx_gather_energy_pink(0, posX, posY, posZ, 0.1f, 13);
208 npc->duration = 15;
209 script->functionTemp[0] = 22;
210 }
211}
s32 * animList
Definition npc.h:341
f32 renderYaw
AnimID curAnim
s16 turnAroundYawAdjustment

◆ FlyingMagikoopaAI_22()

void N FlyingMagikoopaAI_22 ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * territory )

Definition at line 213 of file FlyingMagikoopaAI.inc.c.

213 {
214 Enemy* enemy = script->owner1.enemy;
215 Npc* npc = get_npc_unsafe(enemy->npcID);
216
217 npc->duration--;
218 if (npc->duration <= 0) {
219 npc->curAnim = enemy->animList[9];
220 npc->duration = 7;
221 script->functionTemp[0] = 0x17;
222 }
223}

◆ FlyingMagikoopaAI_23()

void N FlyingMagikoopaAI_23 ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * territory )

Definition at line 225 of file FlyingMagikoopaAI.inc.c.

225 {
226 Enemy* enemy = script->owner1.enemy;
227 Npc* npc = get_npc_unsafe(enemy->npcID);
228 s32 temp_s1;
230
231 npc->duration--;
232 if (npc->duration <= 0) {
233 temp_s1 = N(MagikoopaAI_CanShootSpell)(script, aiSettings->chaseRadius, aiSettings->chaseOffsetDist, territory);
234 if (temp_s1 != 1) {
235 fx_emote(2, npc, 0.0f, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 12, &emoteTemp);
236 npc->curAnim = enemy->animList[0];
237 npc->duration = 15;
238 script->functionTemp[0] = 50;
239 } else {
241 get_enemy(enemy->npcID + 1)->varTable[0] = temp_s1;
242 npc->duration = 20;
243 script->functionTemp[0] = 24;
244 }
245 }
246}
@ SOUND_SPELL_CAST2
Definition enums.h:1502
Enemy * get_enemy(s32 npcID)
Looks for an enemy matching the specified npcID.
Definition npc.c:2537

◆ FlyingMagikoopaAI_24()

void N FlyingMagikoopaAI_24 ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * territory )

Definition at line 248 of file FlyingMagikoopaAI.inc.c.

248 {
249 Enemy* enemy = script->owner1.enemy;
250 Npc* npc = get_npc_unsafe(enemy->npcID);
251 f32 basePosY = (f32)enemy->varTable[1] / 100.0;
252
253 npc->pos.y = basePosY + sin_deg(enemy->varTable[0]) * 6.0;
254 enemy->varTable[0] = clamp_angle(enemy->varTable[0] + 10);
255
256 npc->duration--;
257 if (npc->duration <= 0) {
258 npc->curAnim = enemy->animList[0];
259 npc->duration = 3;
260 script->AI_TEMP_STATE = 50;
261 }
262}

◆ FlyingMagikoopaAI_50()

void N FlyingMagikoopaAI_50 ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * territory )

Definition at line 264 of file FlyingMagikoopaAI.inc.c.

264 {
265 Enemy* enemy = script->owner1.enemy;
266 Npc* npc = get_npc_unsafe(enemy->npcID);
267 f32 basePosY = (f32)enemy->varTable[1] / 100.0;
268
269 npc->pos.y = basePosY + sin_deg(enemy->varTable[0]) * 6.0;
270 enemy->varTable[0] = clamp_angle(enemy->varTable[0] + 10);
271
272 npc->duration--;
273 if (npc->duration <= 0) {
274 script->AI_TEMP_STATE = 10;
275 }
276}