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

Go to the source code of this file.

Data Structures

struct  MagikoopaTeleportAnim
 

Macros

#define ENEMY_FLAG_COMBINATION
 

Functions

void N MagikoopaAI_00 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N MagikoopaAI_01 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N MagikoopaAI_05 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N MagikoopaAI_06 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N MagikoopaAI_10 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N MagikoopaAI_11 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N MagikoopaAI_20 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N MagikoopaAI_21 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N MagikoopaAI_22 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N MagikoopaAI_23 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N MagikoopaAI_24 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 

Data Structure Documentation

◆ MagikoopaTeleportAnim

struct MagikoopaTeleportAnim
Data Fields
f32 scaleX
f32 scaleY
u8 alpha

Macro Definition Documentation

◆ ENEMY_FLAG_COMBINATION

#define ENEMY_FLAG_COMBINATION
Value:
@ ENEMY_FLAG_IGNORE_HAMMER
Definition enums.h:4547
@ ENEMY_FLAG_IGNORE_PARTNER
Definition enums.h:4549
@ ENEMY_FLAG_SKIP_BATTLE
Definition enums.h:4541
@ ENEMY_FLAG_IGNORE_TOUCH
Definition enums.h:4545
@ ENEMY_FLAG_CANT_INTERACT
Definition enums.h:4548
@ ENEMY_FLAG_IGNORE_JUMP
Definition enums.h:4546

Definition at line 11 of file MagikoopaAI.inc.c.

11#define ENEMY_FLAG_COMBINATION (ENEMY_FLAG_IGNORE_PARTNER | ENEMY_FLAG_CANT_INTERACT | \
12 ENEMY_FLAG_IGNORE_HAMMER | ENEMY_FLAG_IGNORE_JUMP | ENEMY_FLAG_IGNORE_TOUCH | ENEMY_FLAG_SKIP_BATTLE)

Referenced by MagikoopaAI_01().

Function Documentation

◆ MagikoopaAI_00()

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

Definition at line 18 of file MagikoopaAI.inc.c.

18 {
19 Enemy* enemy = script->owner1.enemy;
20 Npc* npc = get_npc_unsafe(enemy->npcID);
21
22 npc->duration--;
23 if (npc->duration <= 0) {
25 npc->flags &= ~NPC_FLAG_INVISIBLE;
26 npc->duration = 0;
27 script->AI_TEMP_STATE = 1;
28 }
29}
union Evt::@8 owner1
Initially -1.
@ ENEMY_ANIM_INDEX_IDLE
Definition enums.h:3426
s16 npcID
Definition npc.h:300
s32 * animList
Definition npc.h:341
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:995
Definition npc.h:294
s32 flags
AnimID curAnim
s16 duration

◆ MagikoopaAI_01()

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

Definition at line 31 of file MagikoopaAI.inc.c.

31 {
32 Enemy* enemy = script->owner1.enemy;
33 Npc* npc = get_npc_unsafe(enemy->npcID);
34 npc->scale.x = N(MagikoopaAI_TeleportAnim)[npc->duration].scaleX;
35 npc->scale.y = N(MagikoopaAI_TeleportAnim)[npc->duration].scaleY;
36 npc->alpha = N(MagikoopaAI_TeleportAnim)[npc->duration].alpha;
37
38 npc->duration++;
39 if (npc->duration == 4) {
42 }
43
44 if (N(MagikoopaAI_TeleportAnim)[npc->duration].alpha == 0) {
45 npc->alpha = 0xFF;
46 npc->scale.x = 1.0f;
47 npc->scale.y = 1.0f;
48 npc->scale.z = 1.0f;
50 script->AI_TEMP_STATE = 5;
51 }
52}
#define ENEMY_FLAG_COMBINATION
@ NPC_FLAG_INVISIBLE
Definition enums.h:2999
s32 flags
Definition npc.h:295
void disable_npc_shadow(Npc *npc)
Definition npc.c:1037
Vec3f scale

◆ MagikoopaAI_05()

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

Definition at line 54 of file MagikoopaAI.inc.c.

54 {
55 Npc* npc = get_npc_unsafe(script->owner1.enemy->npcID);
56 f32 angle = (rand_int(100) % 2) * 180.0f;
57
58 npc->duration = 15;
59 npc->moveSpeed = 0.8f;
60 npc->yaw = angle + 90.0f;
61 script->AI_TEMP_STATE = 6;
62}
#define rand_int
f32 moveSpeed

◆ MagikoopaAI_06()

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

Definition at line 64 of file MagikoopaAI.inc.c.

64 {
65 Enemy* enemy = script->owner1.enemy;
66 Npc* npc = get_npc_unsafe(enemy->npcID);
67
68 npc_move_heading(npc, npc->moveSpeed, npc->yaw);
69 npc->duration--;
70 if (npc->duration <= 0) {
71 script->AI_TEMP_STATE = 10;
72 }
73}
void npc_move_heading(Npc *npc, f32 speed, f32 yaw)
Definition npc.c:986

◆ MagikoopaAI_10()

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

Definition at line 75 of file MagikoopaAI.inc.c.

75 {
76 Enemy* enemy = script->owner1.enemy;
77 Npc* npc = get_npc_unsafe(enemy->npcID);
78 f32 dist = dist2D(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
79 f32 posX, posY, posZ;
80
81 enemy->varTable[0] = 1;
82 npc->curAnim = enemy->animList[8];
83 npc->yaw = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
84 npc->flags &= ~NPC_FLAG_INVISIBLE;
85 npc->scale.x = 0.1f;
86 npc->scale.y = 0.1f;
87 npc->scale.z = 0.1f;
88 if (!(npc->flags & NPC_FLAG_FLYING)) {
89 posX = npc->pos.x;
90 dist = 200.0f;
91 posZ = npc->pos.z;
92 posY = npc->pos.y + 100.0;
93 if (npc_raycast_down_sides(npc->collisionChannel, &posX, &posY, &posZ, &dist) != 0) {
94 npc->pos.y = posY;
95 }
96 }
97 npc->duration = 0;
98 script->AI_TEMP_STATE = 0xB;
99}
#define npc_raycast_down_sides
#define atan2
@ NPC_FLAG_FLYING
Definition enums.h:3001
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
s32 collisionChannel
Vec3f pos
PlayerStatus * gPlayerStatusPtr

◆ MagikoopaAI_11()

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

Definition at line 101 of file MagikoopaAI.inc.c.

101 {
102 Enemy* enemy = script->owner1.enemy;
103 Npc* npc = get_npc_unsafe((s32) enemy->npcID);
104 f32 scale;
105 s16 alpha;
106
107 if (enemy->varTable[0] == 0) {
108 alpha = (npc->duration * 15) + 130;
109 } else {
110 alpha = (npc->duration * 15) + 30;
111 }
112 if (alpha > 255) {
113 alpha = 255;
114 }
115 npc->alpha = alpha;
116
117 npc->scale.x = ((f32)npc->duration * 0.1) + 0.4;
118 if (npc->scale.x > 1.0) {
119 npc->scale.x = 1.0f;
120 }
121 npc->scale.y = npc->scale.x;
122 npc->scale.z = npc->scale.x;
123
124 npc->duration++;
125 if (npc->duration == 5) {
127 enemy->flags &= ~ENEMY_FLAG_COMBINATION;
128 }
129 if (enemy->varTable[0] == 0) {
130 if (npc->duration >= 20) {
131 set_npc_imgfx_all(npc->spriteInstanceID, IMGFX_CLEAR, 0, 0, 0, 0, 0);
132 npc->alpha = 255;
133 npc->scale.x = 1.0f;
134 npc->scale.y = 1.0f;
135 npc->scale.z = 1.0f;
136 script->AI_TEMP_STATE = 20;
137 }
138 } else if (npc->duration >= 10) {
139 npc->alpha = 255;
140 npc->scale.x = 1.0f;
141 npc->scale.y = 1.0f;
142 npc->scale.z = 1.0f;
143 script->AI_TEMP_STATE = 20;
144 }
145}
@ IMGFX_CLEAR
Definition enums.h:5117
void enable_npc_shadow(Npc *npc)
Definition npc.c:1027
void set_npc_imgfx_all(s32 spriteIdx, ImgFXType imgfxType, s32 imgfxArg1, s32 imgfxArg2, s32 imgfxArg3, s32 imgfxArg4, s32 imgfxArg5)
Definition sprite.c:1254
s32 spriteInstanceID

◆ MagikoopaAI_20()

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

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

147 {
148 Enemy* enemy = script->owner1.enemy;
149 Npc* npc = get_npc_unsafe(enemy->npcID);
150
151 npc->duration = 40;
152 script->AI_TEMP_STATE = 21;
153}

◆ MagikoopaAI_21()

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

Definition at line 155 of file MagikoopaAI.inc.c.

155 {
156 Enemy* enemy = script->owner1.enemy;
157 Npc* npc = get_npc_unsafe(enemy->npcID);
158 f32 posX, posY, posZ;
159 EffectInstance* emoteTemp;
160
161 npc->duration--;
162 if (npc->duration == 0) {
163 npc->curAnim = enemy->animList[0];
164 fx_emote(2, npc, 0.0f, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 12, &emoteTemp);
165 npc->curAnim = enemy->animList[0];
166 npc->duration = 0xF;
167 script->AI_TEMP_STATE = 0;
168 return;
169 }
170 if (N(MagikoopaAI_CanShootSpell)(script, aiSettings->chaseRadius, aiSettings->chaseOffsetDist, territory) == 1) {
172 npc->curAnim = enemy->animList[8];
173 posX = npc->pos.x;
174 posY = npc->pos.y + 32.0f;
175 posZ = npc->pos.z + 1.0f;
176 add_vec2D_polar(&posX, &posZ, 17.0f, 270.0f - npc->renderYaw);
177 fx_gather_energy_pink(0, posX, posY, posZ, 0.1f, 0xD);
178 npc->duration = 0xF;
179 script->AI_TEMP_STATE = 0x16;
180 }
181}
s32 N MagikoopaAI_CanShootSpell(Evt *script, f32 arg1, f32 arg2, EnemyDetectVolume *territory)
@ SOUND_SPELL_CAST1
Definition enums.h:1498
void ai_enemy_play_sound(Npc *npc, s32 arg1, s32 arg2)
Definition 23680.c:543
void add_vec2D_polar(f32 *x, f32 *y, f32 r, f32 theta)
Definition 43F0.c:685
f32 chaseRadius
Definition npc.h:102
f32 chaseOffsetDist
Definition npc.h:103
f32 renderYaw
s16 collisionHeight

◆ MagikoopaAI_22()

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

Definition at line 183 of file MagikoopaAI.inc.c.

183 {
184 Enemy* temp_s0 = script->owner1.enemy;
185 Npc* temp_v0 = get_npc_unsafe(temp_s0->npcID);
186
187 temp_v0->duration--;
188 if (temp_v0->duration <= 0) {
189 temp_v0->curAnim = temp_s0->animList[9];
190 temp_v0->duration = 9;
191 script->AI_TEMP_STATE = 0x17;
192 }
193}

◆ MagikoopaAI_23()

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

Definition at line 195 of file MagikoopaAI.inc.c.

195 {
196 Enemy* enemy = script->owner1.enemy;
197 Npc* npc = get_npc_unsafe(enemy->npcID);
198 s32 projectileEnemy;
199 EffectInstance* emoteTemp;
200
201 npc->duration--;
202 if (npc->duration <= 0) {
203 projectileEnemy = N(MagikoopaAI_CanShootSpell)(script, aiSettings->chaseRadius, aiSettings->chaseOffsetDist, territory);
204 if (projectileEnemy != 1) {
205 fx_emote(2, npc, 0.0f, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 0xC, &emoteTemp);
206 npc->curAnim = enemy->animList[0];
207 npc->duration = 15;
208 script->AI_TEMP_STATE = 0;
209 } else {
211 get_enemy(enemy->npcID + 1)->varTable[0] = projectileEnemy;
212 npc->duration = 0x14;
213 script->AI_TEMP_STATE = 0x18;
214 }
215 }
216}
@ SOUND_SPELL_CAST2
Definition enums.h:1499
Enemy * get_enemy(s32 npcID)
Looks for an enemy matching the specified npcID.
Definition npc.c:2540

◆ MagikoopaAI_24()

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

Definition at line 218 of file MagikoopaAI.inc.c.

218 {
219 Enemy* enemy = script->owner1.enemy;
220 Npc* npc = get_npc_unsafe(enemy->npcID);
221
222 npc->duration--;
223 if (npc->duration <= 0) {
224 npc->curAnim = enemy->animList[0];
225 npc->duration = 3;
226 script->AI_TEMP_STATE = 0;
227 }
228}