Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
koopa_troopa.inc.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects.h"
3#include "battle/battle.h"
4#include "script_api/battle.h"
5#include "sprite/npc/KoopaTroopa.h"
6
7#define NAMESPACE A(koopa_troopa)
8
9extern s32 N(DefaultAnims)[];
10extern EvtScript N(EVS_Init);
11extern EvtScript N(EVS_Idle);
12extern EvtScript N(EVS_TakeTurn);
13extern EvtScript N(EVS_HandleEvent);
14
15enum N(ActorPartIDs) {
16 PRT_MAIN = 1,
17};
18
19enum N(ActorVars) {
22};
23
24enum N(ActorParams) {
26};
27
28s32 N(NormalDefense)[] = {
31 ELEMENT_JUMP, 1,
35};
36
37s32 N(FlippedDefense)[] = {
40};
41
42s32 N(StatusTable)[] = {
53 STATUS_KEY_STOP, 100,
65};
66
67ActorPartBlueprint N(ActorParts)[] = {
68 {
70 .index = PRT_MAIN,
71 .posOffset = { 0, 0, 0 },
72 .targetOffset = { -2, 36 },
73 .opacity = 255,
74 .idleAnimations = N(DefaultAnims),
75 .defenseTable = N(NormalDefense),
76 .eventFlags = ACTOR_EVENT_FLAG_FLIPABLE,
77 .elementImmunityFlags = 0,
78 .projectileTargetOffset = { 0, -7 },
79 },
80};
81
82ActorBlueprint NAMESPACE = {
83 .flags = 0,
86 .maxHP = 4,
87 .partCount = ARRAY_COUNT(N(ActorParts)),
88 .partsData = N(ActorParts),
89 .initScript = &N(EVS_Init),
90 .statusTable = N(StatusTable),
91 .escapeChance = 70,
92 .airLiftChance = 90,
93 .hurricaneChance = 90,
94 .spookChance = 90,
95 .upAndAwayChance = 95,
96 .spinSmashReq = 0,
97 .powerBounceChance = 100,
98 .coinReward = 1,
99 .size = { 28, 36 },
100 .healthBarOffset = { 0, 0 },
101 .statusIconOffset = { -15, 32 },
102 .statusTextOffset = { 5, 32 },
103};
104
105s32 N(DefaultAnims)[] = {
116};
117
118s32 N(ShuffleAnims)[] = {
129};
130
131s32 N(FlippedAnims)[] = {
142};
143
144EvtScript N(EVS_Init) = {
145 Call(BindTakeTurn, ACTOR_SELF, Ref(N(EVS_TakeTurn)))
146 Call(BindIdle, ACTOR_SELF, Ref(N(EVS_Idle)))
147 Call(BindHandleEvent, ACTOR_SELF, Ref(N(EVS_HandleEvent)))
149 Return
150 End
151};
152
154
157 CaseEq(0)
159 Call(SetTargetOffset, ACTOR_SELF, PRT_MAIN, -5, 15)
161 Call(N(SetAbsoluteStatusOffsets), -10, 20, 10, 20)
162 Else
163 Call(SetTargetOffset, ACTOR_SELF, PRT_MAIN, -4, 32)
164 Call(SetProjectileTargetOffset, ACTOR_SELF, PRT_MAIN, -1, -4)
165 Call(N(SetAbsoluteStatusOffsets), -15, 32, 5, 32)
166 EndIf
167 CaseEq(1)
168 Call(SetTargetOffset, ACTOR_SELF, PRT_MAIN, -5, 15)
170 Call(N(SetAbsoluteStatusOffsets), -10, 20, 10, 20)
172 Return
173 End
174};
175
176EvtScript N(EVS_Idle) = {
177 Label(0)
178 Call(RandInt, 80, LVarA)
179 Add(LVarA, 80)
180 Loop(LVarA)
181 Label(1)
185 IfEq(LVar0, 1)
186 Wait(1)
187 Goto(1)
188 EndIf
190 Wait(1)
191 Goto(1)
192 EndIf
193 Wait(1)
194 EndLoop
196 Add(LVar0, 5)
198 Call(SetIdleAnimations, ACTOR_SELF, PRT_MAIN, Ref(N(ShuffleAnims)))
203 CaseEq(0)
204 Call(SetIdleAnimations, ACTOR_SELF, PRT_MAIN, Ref(N(DefaultAnims)))
205 CaseEq(1)
208 Loop(20)
209 Label(2)
213 IfEq(LVar0, 1)
214 Wait(1)
215 Goto(2)
216 EndIf
218 Wait(1)
219 Goto(2)
220 EndIf
221 Wait(1)
222 EndLoop
224 Sub(LVar0, 5)
226 Call(SetIdleAnimations, ACTOR_SELF, PRT_MAIN, Ref(N(ShuffleAnims)))
231 CaseEq(0)
232 Call(SetIdleAnimations, ACTOR_SELF, PRT_MAIN, Ref(N(DefaultAnims)))
233 CaseEq(1)
236 Loop(80)
237 Label(3)
241 IfEq(LVar0, 1)
242 Wait(1)
243 Goto(3)
244 EndIf
246 Wait(1)
247 Goto(3)
248 EndIf
249 Wait(1)
250 EndLoop
251 Goto(0)
252 Return
253 End
254};
255
256s32 N(FlipPosOffsets)[] = { 9, 16, 22, 26, 30, 32, 33, 32, 30, 26, 22, 16, 9, 0, 4, 6, 7, 6, 4, 0, 2, 0 };
257
258EvtScript N(EVS_HandleEvent) = {
266 SetConst(LVar0, PRT_MAIN)
271 SetConst(LVar0, PRT_MAIN)
276 SetConst(LVar0, PRT_MAIN)
280 SetConst(LVar0, PRT_MAIN)
283 Return
285 SetConst(LVar0, PRT_MAIN)
289 SetConst(LVar0, PRT_MAIN)
292 SetConst(LVar0, PRT_MAIN)
295 Return
301 Call(SetTargetOffset, ACTOR_SELF, PRT_MAIN, -5, 15)
308 Wait(4)
310 Wait(1)
312 Wait(1)
313 Call(SetActorRotation, ACTOR_SELF, 0, 0, -30)
314 Wait(1)
315 Call(SetActorRotation, ACTOR_SELF, 0, 0, -60)
316 Wait(1)
317 Call(SetActorRotation, ACTOR_SELF, 0, 0, -75)
318 Wait(1)
324 Wait(1)
325 EndLoop
331 SetConst(LVar0, PRT_MAIN)
334 SetConst(LVar0, PRT_MAIN)
338 SetConst(LVar0, PRT_MAIN)
344 SetConst(LVar0, PRT_MAIN)
347 SetConst(LVar0, PRT_MAIN)
350 Return
354 IfEq(LVar0, 0)
355 SetConst(LVar0, PRT_MAIN)
361 Wait(10)
362 EndIf
363 Else
364 SetConst(LVar0, PRT_MAIN)
367 EndIf
370 SetConst(LVar0, PRT_MAIN)
373 Wait(10)
374 SetConst(LVar0, PRT_MAIN)
377 Return
380 IfEq(LVar0, 0)
381 SetConst(LVar0, PRT_MAIN)
384 EndIf
390 IfEq(LVar0, 0)
391 SetConst(LVar0, PRT_MAIN)
394 Else
395 SetConst(LVar0, PRT_MAIN)
398 EndIf
401 IfEq(LVar0, 0)
402 SetConst(LVar0, PRT_MAIN)
406 Return
407 Else
408 SetConst(LVar0, PRT_MAIN)
411 EndIf
414 IfEq(LVar0, 0)
415 SetConst(LVar0, PRT_MAIN)
417 Else
418 SetConst(LVar0, PRT_MAIN)
420 EndIf
424 IfEq(LVar0, 0)
425 SetConst(LVar0, PRT_MAIN)
427 Else
428 SetConst(LVar0, PRT_MAIN)
430 EndIf
432 Return
435 IfEq(LVar0, 0)
436 SetConst(LVar0, PRT_MAIN)
439 Else
440 SetConst(LVar0, PRT_MAIN)
443 EndIf
447 Return
448 End
449};
450
451EvtScript N(EVS_TakeTurn) = {
458 Else
460 IfEq(LVar0, 1)
462 Sub(LVar0, 1)
463 IfGt(LVar0, 0)
466 Call(SetAnimationRate, ACTOR_SELF, PRT_MAIN, Float(3.0))
467 Wait(30)
468 Call(SetAnimationRate, ACTOR_SELF, PRT_MAIN, Float(1.0))
470 Else
472 Call(SetAnimationRate, ACTOR_SELF, PRT_MAIN, Float(3.0))
473 Wait(20)
474 Call(SetAnimationRate, ACTOR_SELF, PRT_MAIN, Float(1.0))
479 Set(LVar0, 0)
482 Loop(5)
483 Add(LVar0, 15)
485 Wait(1)
486 EndLoop
498 Call(SetIdleAnimations, ACTOR_SELF, PRT_MAIN, Ref(N(DefaultAnims)))
500 Call(SetTargetOffset, ACTOR_SELF, PRT_MAIN, -4, 32)
501 Call(SetProjectileTargetOffset, ACTOR_SELF, PRT_MAIN, -1, -4)
504 EndIf
507 Return
508 EndIf
511 Wait(10)
513 Wait(10)
516 Add(LVar1, 4)
517 PlayEffect(EFFECT_SMOKE_IMPACT, 1, LVar0, LVar1, LVar2, 32, 4, 0, 10, 0)
518 Wait(3)
519 PlayEffect(EFFECT_SMOKE_IMPACT, 1, LVar0, LVar1, LVar2, 32, 4, 0, 10, 0)
520 Wait(2)
521 PlayEffect(EFFECT_SMOKE_IMPACT, 1, LVar0, LVar1, LVar2, 32, 4, 0, 10, 0)
525 Wait(10)
527 EndIf
534 Set(LVarA, LVar0)
536 Call(AddGoalPos, ACTOR_SELF, -40, 0, 0)
546 EndIf
548 Wait(8)
551 Wait(4)
554 EndIf
556 Wait(1)
559 Add(LVar1, 20)
564 Wait(6)
565 Sub(LVar1, 20)
578 Call(SetPartYaw, ACTOR_SELF, PRT_MAIN, 0)
582 Return
589 Wait(2)
596 Add(LVar0, 40)
597 Set(LVar1, 0)
601 Add(LVar0, 30)
604 Add(LVar0, 20)
608 Wait(8)
610 SetConst(LVar0, PRT_MAIN)
618 Return
619 End
620};
BSS s32 PopupMenu_SelectedIndex
Bytecode EvtScript[]
#define STATUS_FLAGS_IMMOBILIZED
Definition enums.h:2834
@ BTL_CAM_XADJ_AVG
Definition enums.h:4899
@ ACTOR_SOUND_WALK
Definition enums.h:2034
@ ACTOR_SOUND_JUMP
Definition enums.h:2036
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3574
@ BS_FLAGS1_INCLUDE_POWER_UPS
Definition enums.h:3570
@ ELEMENT_JUMP
Definition enums.h:2122
@ ELEMENT_END
Definition enums.h:2114
@ ELEMENT_BLAST
Definition enums.h:2124
@ ELEMENT_SMASH
Definition enums.h:2121
@ ELEMENT_WATER
Definition enums.h:2117
@ ELEMENT_NORMAL
Definition enums.h:2115
@ ACTOR_EVENT_FLAG_FLIPABLE
Actor can be flipped; triggered by jump and quake attacks.
Definition enums.h:3380
@ ACTOR_DECORATION_SWEAT
Definition enums.h:2045
@ PHASE_FIRST_STRIKE
Definition enums.h:2059
@ STATUS_KEY_PARALYZE
Definition enums.h:2201
@ STATUS_TURN_MOD_DEFAULT
Definition enums.h:2227
@ STATUS_TURN_MOD_PARALYZE
Definition enums.h:2234
@ STATUS_KEY_FROZEN
Definition enums.h:2203
@ STATUS_TURN_MOD_SLEEP
Definition enums.h:2228
@ STATUS_TURN_MOD_DIZZY
Definition enums.h:2232
@ STATUS_KEY_STATIC
Definition enums.h:2207
@ STATUS_END
Definition enums.h:2196
@ STATUS_TURN_MOD_POISON
Definition enums.h:2233
@ STATUS_KEY_FEAR
Definition enums.h:2199
@ STATUS_TURN_MOD_STOP
Definition enums.h:2237
@ STATUS_KEY_SLEEP
Definition enums.h:2202
@ STATUS_KEY_STONE
Definition enums.h:2208
@ STATUS_KEY_STOP
Definition enums.h:2204
@ STATUS_TURN_MOD_FROZEN
Definition enums.h:2230
@ STATUS_KEY_SHRINK
Definition enums.h:2206
@ STATUS_KEY_DIZZY
Definition enums.h:2200
@ STATUS_KEY_POISON
Definition enums.h:2205
@ STATUS_TURN_MOD_STATIC
Definition enums.h:2229
@ STATUS_TURN_MOD_FEAR
Definition enums.h:2231
@ STATUS_KEY_NORMAL
Definition enums.h:2197
@ STATUS_TURN_MOD_SHRINK
Definition enums.h:2235
@ STATUS_KEY_DEFAULT
Definition enums.h:2198
@ HIT_RESULT_NO_DAMAGE
Definition enums.h:1952
@ HIT_RESULT_HIT
Definition enums.h:1950
@ HIT_RESULT_LUCKY
Definition enums.h:1955
@ HIT_RESULT_MISS
Definition enums.h:1956
@ BTL_CAM_ACTOR_TARGET_MIDPOINT
Definition enums.h:4826
@ BTL_CAM_DEFAULT
Definition enums.h:4823
@ BTL_CAM_ENEMY_APPROACH
Definition enums.h:4884
@ SUPPRESS_EVENT_ALL
Definition enums.h:2907
@ IDLE_SCRIPT_RESTART
Definition enums.h:6408
@ IDLE_SCRIPT_ENABLE
Definition enums.h:6407
@ IDLE_SCRIPT_DISABLE
Definition enums.h:6406
@ STATUS_FLAG_DIZZY
Definition enums.h:2818
@ STATUS_FLAG_SLEEP
Definition enums.h:2812
@ SOUND_NONE
Definition enums.h:547
@ SOUND_ACTOR_STEP_A
Definition enums.h:1474
@ SOUND_SHELL_SPIN
Definition enums.h:1342
@ SOUND_SHELL_TOSS
Definition enums.h:1497
@ SOUND_ACTOR_JUMP
Definition enums.h:1290
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_SELF
Definition enums.h:2084
@ ACTOR_FLAG_FLIPPED
Actor has been flipped over.
Definition enums.h:3330
@ BTL_CAM_YADJ_TARGET
Definition enums.h:4904
@ EVENT_HIT
Definition enums.h:2132
@ EVENT_SCARE_AWAY
Definition enums.h:2174
@ EVENT_BURN_HIT
Definition enums.h:2136
@ EVENT_END_FIRST_STRIKE
Definition enums.h:2171
@ EVENT_IMMUNE
Definition enums.h:2146
@ EVENT_BURN_DEATH
Definition enums.h:2157
@ EVENT_ZERO_DAMAGE
Definition enums.h:2144
@ EVENT_SHOCK_DEATH
Definition enums.h:2159
@ EVENT_SPIN_SMASH_HIT
Definition enums.h:2133
@ EVENT_SPIN_SMASH_DEATH
Definition enums.h:2154
@ EVENT_HIT_COMBO
Definition enums.h:2131
@ EVENT_AIR_LIFT_FAILED
Definition enums.h:2152
@ EVENT_BEGIN_AIR_LIFT
Definition enums.h:2175
@ EVENT_DEATH
Definition enums.h:2153
@ EVENT_FLIP_TRIGGER
Definition enums.h:2135
@ EVENT_SHOCK_HIT
Definition enums.h:2165
@ EVENT_RECOVER_STATUS
Definition enums.h:2167
@ EVENT_BLOW_AWAY
Definition enums.h:2143
@ ACTOR_PART_FLAG_PRIMARY_TARGET
Definition enums.h:3362
@ DAMAGE_TYPE_TRIGGER_LUCKY
Definition enums.h:2881
EvtScript EVS_Enemy_ReturnHome
EvtScript EVS_Enemy_Knockback
EvtScript EVS_Enemy_ScareAway
EvtScript EVS_Enemy_Hit
EvtScript EVS_Enemy_Death
EvtScript EVS_Enemy_SpinSmashHit
EvtScript EVS_Enemy_ShockHit
EvtScript EVS_Enemy_AirLift
EvtScript EVS_Enemy_BlowAway
EvtScript EVS_Enemy_Recover
EvtScript EVS_Enemy_BurnHit
EvtScript EVS_Enemy_NoDamageHit
ApiStatus RandInt(Evt *script, b32 isInitialCall)
#define Else
Marks the end of an if statement and the start of the else block.
Definition macros.h:295
#define Switch(LVAR)
Marks the start of a switch statement.
Definition macros.h:311
#define Ref(sym)
Address/pointer constant.
Definition macros.h:60
#define Set(VAR, INT_VALUE)
Sets the given variable to a given value casted to an integer.
Definition macros.h:365
#define CaseEq(RVAR)
Marks the start of a switch case that executes only if LVAR == RVAR. It also marks the end of any pre...
Definition macros.h:319
#define EndChildThread
Marks the end of a child thread block.
Definition macros.h:563
#define Sub(VAR, INT_VALUE)
Definition macros.h:377
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:213
#define UseBuf(INT_PTR)
Loads a s32 pointer for use with subsequent EVT_BUF_READ commands.
Definition macros.h:389
#define Add(VAR, INT_VALUE)
Definition macros.h:376
#define EndLoop
Marks the end of a loop.
Definition macros.h:248
#define EndCaseGroup
Marks the end of a switch case group (CaseOrEq and/or CaseAndEq), stopping fallthrough.
Definition macros.h:352
#define Goto(LABEL_ID)
Moves execution to the given label.
Definition macros.h:232
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define BufRead1(VAR)
Consumes the next s32 from the buffer and stores it in the given variable.
Definition macros.h:392
#define IfGt(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR <= RVAR.
Definition macros.h:278
#define Float(DOUBLE)
Definition macros.h:51
#define Label(LABEL_ID)
Marks this point in the script as a Goto target.
Definition macros.h:227
#define CaseOrEq(RVAR)
Marks the start of a switch case that executes only if LVAR == RVAR.
Definition macros.h:341
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:298
#define ExecWait(EVT_SOURCE)
Launches a new child thread.
Definition macros.h:475
#define IfFlag(LVAR, RVAR)
Marks the beginning of an if statement that only executes if the RVAR flag is set on LVAR,...
Definition macros.h:288
#define LVar2
Definition macros.h:150
#define LVar1
Definition macros.h:149
#define LVarA
Definition macros.h:158
#define IfNotFlag(LVAR, RVAR)
Marks the beginning of an if statement that only executes if the RVAR flag is unset on LVAR,...
Definition macros.h:292
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#define PlayEffect(args...)
Definition macros.h:807
#define EndSwitch
Marks the end of a switch statement and any case.
Definition macros.h:362
#define IfEq(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR == RVAR.
Definition macros.h:269
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:576
#define ChildThread
Marks the start of a child thread block.
Definition macros.h:560
#define Loop(TIMES)
Marks the beginning of a loop.
Definition macros.h:245
#define LVar0
Definition macros.h:148
#define SetConst(VAR, CONST)
Sets the given variable to a given value, skipping the evt_get_variable call.
Definition macros.h:370
#define Return
Kills the current EVT thread.
Definition macros.h:217