Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
bandit.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/Bandit.h"
6
7#define NAMESPACE A(bandit)
8
9extern EvtScript N(EVS_Init);
10extern EvtScript N(EVS_Idle);
11extern EvtScript N(EVS_Init_Coin);
12extern EvtScript N(EVS_TakeTurn);
14
15BSS s32 N(DropCoinScript)[1];
16
17enum N(ActorPartIDs) {
18 PRT_MAIN = 1,
19 PRT_COIN = 2,
20};
21
22enum N(ActorVars) {
23 AVAR_HasCoin = 0, // has stolen coins
24 AVAR_NumCoins = 1, // number of coins stolen
25 AVAR_Coin_NumCoins = 1, // number of coins stolen also stored in coin actor
26};
27
28enum N(ActorParams) {
29 DMG_TACKLE = 2,
30};
31
32s32 N(DefaultAnims)[] = {
43};
44
45s32 N(HoldingAnims)[] = {
56};
57
58s32 N(CoinAnims)[] = {
61};
62
63s32 N(DefenseTable)[] = {
66};
67
68s32 N(StatusTable)[] = {
79 STATUS_KEY_STOP, 100,
91};
92
94 {
96 .index = PRT_MAIN,
97 .posOffset = { 0, 0, 0 },
98 .targetOffset = { -2, 28 },
99 .opacity = 255,
100 .idleAnimations = N(DefaultAnims),
101 .defenseTable = N(DefenseTable),
102 .eventFlags = ACTOR_EVENT_FLAGS_NONE,
103 .elementImmunityFlags = 0,
104 .projectileTargetOffset = { 0, -12 },
105 },
106 {
108 .index = PRT_COIN,
109 .posOffset = { 0, 30, 0 },
110 .targetOffset = { 0, 0 },
111 .opacity = 255,
112 .idleAnimations = N(CoinAnims),
113 .defenseTable = N(DefenseTable),
114 .eventFlags = ACTOR_EVENT_FLAGS_NONE,
115 .elementImmunityFlags = 0,
116 .projectileTargetOffset = { 0, 0 },
117 },
118};
119
121 {
123 .index = PRT_COIN,
124 .posOffset = { 0, 0, 0 },
125 .targetOffset = { 0, 0 },
126 .opacity = 255,
127 .idleAnimations = N(CoinAnims),
128 .defenseTable = N(DefenseTable),
129 .eventFlags = ACTOR_EVENT_FLAGS_NONE,
130 .elementImmunityFlags = 0,
131 .projectileTargetOffset = { 0, 0 },
132 },
133};
134
135ActorBlueprint NAMESPACE = {
136 .flags = 0,
137 .type = ACTOR_TYPE_BANDIT,
138 .level = ACTOR_LEVEL_BANDIT,
139 .maxHP = 5,
140 .partCount = ARRAY_COUNT(N(ActorParts)),
141 .partsData = N(ActorParts),
142 .initScript = &N(EVS_Init),
143 .statusTable = N(StatusTable),
144 .escapeChance = 40,
145 .airLiftChance = 90,
146 .hurricaneChance = 90,
147 .spookChance = 90,
148 .upAndAwayChance = 95,
149 .spinSmashReq = 0,
150 .powerBounceChance = 80,
151 .coinReward = 1,
152 .size = { 26, 32 },
153 .healthBarOffset = { 0, 0 },
154 .statusIconOffset = { -10, 25 },
155 .statusTextOffset = { 10, 25 },
156};
157
158ActorBlueprint N(coin) = {
160 .type = ACTOR_TYPE_BANDIT,
161 .level = ACTOR_LEVEL_BANDIT,
162 .maxHP = 5,
163 .partCount = ARRAY_COUNT(N(CoinParts)),
164 .partsData = N(CoinParts),
165 .initScript = &N(EVS_Init_Coin),
166 .statusTable = N(StatusTable),
167 .escapeChance = 40,
168 .airLiftChance = 90,
169 .hurricaneChance = 90,
170 .spookChance = 90,
171 .upAndAwayChance = 95,
172 .spinSmashReq = 0,
173 .powerBounceChance = 80,
174 .coinReward = 1,
175 .size = { 26, 32 },
176 .healthBarOffset = { 0, 0 },
177 .statusIconOffset = { -10, 25 },
178 .statusTextOffset = { 10, 25 },
179};
180
182
184 ACTOR_BY_POS(N(coin), N(CoinPos), 0),
185};
186
187EvtScript N(EVS_Init) = {
192 Return
193 End
194};
195
196EvtScript N(EVS_Dummy) = {
197 Return
198 End
199};
200
205 Return
206 End
207};
208
209EvtScript N(EVS_Idle) = {
210 Return
211 End
212};
213
218 // do nothing
219 CaseEq(TRUE)
224 Set(LVarA, LVar0)
231 Call(RandInt, 360, LVar0)
233 Add(LVar2, 30)
248 Loop(0)
252 EndIf
255 EndIf
256 Wait(1)
257 EndLoop
258 Wait(15)
261 Set(LVar0, -70)
262 Set(LVar1, 0)
263 Set(LVar2, 10)
264 Label(5)
267 Goto(10)
268 EndIf
270 Set(LVar4, LVar0)
271 Sub(LVar4, LVar3)
272 IfLt(LVar4, 30)
276 Else
277 Set(LVar4, LVar3)
278 Add(LVar3, 30)
282 EndIf
283 Else
284 Set(LVar4, LVar3)
285 Sub(LVar4, LVar0)
286 IfLt(LVar4, 30)
290 Else
291 Sub(LVar3, 30)
295 EndIf
296 EndIf
297 Goto(5)
298 Label(10)
310 Return
311 End
312};
313
325 Loop(0)
327 IfEq(LVar0, 0)
329 EndIf
330 Wait(1)
331 EndLoop
338 Loop(0)
340 IfEq(LVar0, 0)
342 EndIf
343 Wait(1)
344 EndLoop
352 Loop(0)
354 IfEq(LVar0, 0)
356 EndIf
357 Wait(1)
358 EndLoop
368 Loop(0)
370 IfEq(LVar0, 0)
372 EndIf
373 Wait(1)
374 EndLoop
375 Return
381 Loop(0)
383 IfEq(LVar0, 0)
385 EndIf
386 Wait(1)
387 EndLoop
396 Loop(0)
398 IfEq(LVar0, 0)
400 EndIf
401 Wait(1)
402 EndLoop
403 Return
423 Return
429 CaseEq(0)
431 CaseEq(1)
443 Wait(10)
447 Loop(0)
449 IfEq(LVar0, 0)
451 EndIf
452 Wait(1)
453 EndLoop
454 Return
466 Loop(0)
468 IfEq(LVar0, 0)
470 EndIf
471 Wait(1)
472 EndLoop
473 Return
479 Loop(0)
481 IfEq(LVar0, 0)
483 EndIf
484 Wait(1)
485 EndLoop
491 Return
497 Return
498 End
499};
500
505 // if carrying a coin, run away
507 IfEq(LVar0, 1)
510 Wait(30)
512 Call(SetGoalPos, ACTOR_SELF, 300, 0, 0)
517 Return
518 EndIf
526 Add(LVar0, 50)
527 Set(LVar1, 0)
529 Else
532 Call(AddGoalPos, ACTOR_SELF, 50, 0, 0)
536 Wait(6)
537 EndIf
541 Call(AddGoalPos, ACTOR_SELF, 35, 0, 0)
549 Set(LVarA, LVar0)
558 Sub(LVar0, 30)
561 Sub(LVar0, 20)
564 Wait(5)
567 EndIf
568 Wait(5)
582 Return
590 Wait(2)
595 // dont steal coins if no damage, blocked
597 IfLe(LVar0, 0)
598 Set(LVar0, 1)
599 Goto(10)
600 EndIf
603 Set(LVar0, 1)
604 Goto(10)
605 EndIf
606 // cant steal coins if shrunk
609 Set(LVar0, 0)
610 Goto(10)
611 EndIf
612 // cant steal coins if player is stone
615 Set(LVar0, 0)
616 Goto(10)
617 EndIf
618 Call(AddCoin, 0)
619 // choose outcome based on stolen coin count
621 CaseEq(0)
622 Set(LVar0, 1)
623 CaseLt(10)
625 Set(LVar0, 2)
626 CaseGe(10)
627 // cap num stolen to 10
629 Set(LVar0, 2)
631 Label(10)
633 CaseEq(0)
634 // couldn't steal (from shrunk or player stone)
636 Add(LVar0, 30)
637 Set(LVar1, 0)
642 Wait(20)
644 CaseEq(1)
645 // failed to steal (player blocked or damage negated)
647 Add(LVar0, 30)
648 Set(LVar1, 0)
653 Wait(20)
656 Wait(20)
659 // stole coins
662 Add(LVarA, 30)
663 Set(LVarB, 0)
665 Mul(LVar0, -1)
667 Thread
673 Add(LVarB, 30)
677 Thread
679 Loop(LVar0)
681 Wait(1)
682 EndLoop
690 Wait(7)
692 Wait(20)
704 Return
705 End
706};
BSS s32 PopupMenu_SelectedIndex
Bytecode EvtScript[]
@ BTL_CAM_XADJ_AVG
Definition enums.h:4899
@ ACTOR_SOUND_WALK
Definition enums.h:2034
@ ACTOR_SOUND_JUMP
Definition enums.h:2036
@ BS_FLAGS1_BATTLE_FLED
Definition enums.h:3586
@ BS_FLAGS1_PARTNER_ACTING
Definition enums.h:3587
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3574
@ BS_FLAGS1_ATK_BLOCKED
Definition enums.h:3599
@ BS_FLAGS1_INCLUDE_POWER_UPS
Definition enums.h:3570
@ BS_FLAGS1_EXECUTING_MOVE
Definition enums.h:3577
@ ELEMENT_END
Definition enums.h:2114
@ ELEMENT_NORMAL
Definition enums.h:2115
@ ACTOR_EVENT_FLAGS_NONE
Definition enums.h:3370
@ 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_DEFAULT
Definition enums.h:4823
@ BTL_CAM_ENEMY_APPROACH
Definition enums.h:4884
@ IDLE_SCRIPT_ENABLE
Definition enums.h:6407
@ IDLE_SCRIPT_DISABLE
Definition enums.h:6406
@ STATUS_FLAG_SHRINK
Definition enums.h:2819
@ STATUS_FLAG_STONE
Definition enums.h:2820
@ STATUS_FLAG_DIZZY
Definition enums.h:2818
@ SOUND_COIN_BOUNCE
Definition enums.h:923
@ SOUND_NONE
Definition enums.h:547
@ SOUND_BANDIT_STEAL
Definition enums.h:1481
@ SOUND_COIN_PICKUP
Definition enums.h:922
@ SOUND_DISAPPOINTED
Definition enums.h:1482
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_SELF
Definition enums.h:2084
@ ACTOR_FLAG_NO_DMG_APPLY
Damage is not applied to actor HP.
Definition enums.h:3340
@ ACTOR_FLAG_NO_ATTACK
Skip attack turn.
Definition enums.h:3339
@ BTL_CAM_YADJ_TARGET
Definition enums.h:4904
@ ACTOR_BLUR_ENABLE
Definition enums.h:6413
@ EVENT_HIT
Definition enums.h:2132
@ EVENT_SPIN_SMASH_LAUNCH_HIT
Definition enums.h:2138
@ EVENT_SCARE_AWAY
Definition enums.h:2174
@ EVENT_BURN_HIT
Definition enums.h:2136
@ 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_SPIN_SMASH_LAUNCH_DEATH
Definition enums.h:2158
@ 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
@ ACTOR_PART_FLAG_USE_ABSOLUTE_POSITION
Definition enums.h:3361
@ ACTOR_PART_FLAG_NO_TARGET
Cannot be targeted.
Definition enums.h:3360
@ ACTOR_PART_FLAG_INVISIBLE
Definition enums.h:3350
@ 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 AddVectorPolar(Evt *script, b32 isInitialCall)
ApiStatus RandInt(Evt *script, b32 isInitialCall)
ApiStatus AddCoin(Evt *script, b32 isInitialCall)
#define ArrayVar(INDEX)
User Word.
Definition macros.h:122
#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 Mul(VAR, INT_VALUE)
Definition macros.h:378
#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 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 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 CaseGe(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:334
#define Goto(LABEL_ID)
Moves execution to the given label.
Definition macros.h:232
#define BSS
Definition macros.h:7
#define LVarC
Definition macros.h:160
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define IfLt(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR < RVAR.
Definition macros.h:275
#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 IsThreadRunning(TID, OUTVAR)
Sets OUTVAR to TRUE/FALSE depending on whether a thread with the given ID exists (i....
Definition macros.h:540
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:298
#define LVar5
Definition macros.h:153
#define CaseDefault
Marks the start of a switch case that executes unconditionally. It also marks the end of any previous...
Definition macros.h:337
#define LVarB
Definition macros.h:159
#define ExecWait(EVT_SOURCE)
Launches a new child thread.
Definition macros.h:475
#define IfLe(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR > RVAR.
Definition macros.h:281
#define BreakLoop
Breaks out of the innermost loop.
Definition macros.h:251
#define Thread
Marks the start of a thread block.
Definition macros.h:544
#define EndThread
Marks the end of a thread block.
Definition macros.h:547
#define UseArray(INT_PTR)
Loads an s32 array pointer into the current thread for use with ArrayVar(INDEX).
Definition macros.h:425
#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 ExecGetTID(EVT_SOURCE, OUTVAR)
Identical to Exec, but the newly-launched thread ID is stored in OUTVAR.
Definition macros.h:460
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#define NPC_DISPOSE_LOCATION
Definition macros.h:162
#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 CaseLt(RVAR)
Marks the start of a switch case that executes only if LVAR < RVAR. It also marks the end of any prev...
Definition macros.h:325
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:576
#define Loop(TIMES)
Marks the beginning of a loop.
Definition macros.h:245
#define LVar4
Definition macros.h:152
#define LVar3
Definition macros.h:151
#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
#define ACTOR_BY_POS(_name, _pos, _priority, args...)
Definition battle.h:230
FormationRow Formation[]
Definition battle.h:167