Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
whacka.inc.c
Go to the documentation of this file.
1#include "battle/battle.h"
2#include "script_api/battle.h"
3#include "sprite/npc/Whacka.h"
4
5#define NAMESPACE A(whacka)
6
7extern EvtScript N(EVS_Init);
8extern EvtScript N(EVS_Idle);
9extern EvtScript N(EVS_TakeTurn);
10extern EvtScript N(EVS_HandleEvent);
11extern EvtScript N(EVS_MakeWhackaBump);
12extern EvtScript N(EVS_Death);
13
14enum N(ActorPartIDs) {
15 PRT_MAIN = 1,
16};
17
18enum N(ActorVars) {
19 AVAR_SpawnedBump = 0,
20};
21
22s32 N(DefaultAnims)[] = {
23 STATUS_KEY_NORMAL, ANIM_Whacka_Idle,
24 STATUS_KEY_STONE, ANIM_Whacka_Still,
25 STATUS_KEY_SLEEP, ANIM_Whacka_Idle,
26 STATUS_KEY_POISON, ANIM_Whacka_Idle,
27 STATUS_KEY_STOP, ANIM_Whacka_Still,
28 STATUS_KEY_STATIC, ANIM_Whacka_Idle,
29 STATUS_KEY_PARALYZE, ANIM_Whacka_Still,
30 STATUS_KEY_DIZZY, ANIM_Whacka_Idle,
31 STATUS_KEY_FEAR, ANIM_Whacka_Idle,
33};
34
35s32 N(DefenseTable)[] = {
38};
39
40s32 N(StatusTable)[] = {
63};
64
65ActorPartBlueprint N(ActorParts)[] = {
66 {
68 .index = PRT_MAIN,
69 .posOffset = { 0, 0, 0 },
70 .targetOffset = { 0, 30 },
71 .opacity = 255,
72 .idleAnimations = N(DefaultAnims),
73 .defenseTable = N(DefenseTable),
74 .eventFlags = ACTOR_EVENT_FLAGS_NONE,
75 .elementImmunityFlags = 0,
76 .projectileTargetOffset = { 0, -5 },
77 },
78};
79
80ActorBlueprint NAMESPACE = {
82 .type = ACTOR_TYPE_WHACKA,
83 .level = ACTOR_LEVEL_WHACKA,
84 .maxHP = 99,
85 .partCount = ARRAY_COUNT(N(ActorParts)),
86 .partsData = N(ActorParts),
87 .initScript = &N(EVS_Init),
88 .statusTable = N(StatusTable),
89 .escapeChance = 0,
90 .airLiftChance = 0,
91 .hurricaneChance = 0,
92 .spookChance = 0,
93 .upAndAwayChance = 0,
94 .spinSmashReq = 4,
95 .powerBounceChance = 50,
96 .coinReward = 0,
97 .size = { 47, 32 },
98 .healthBarOffset = { 0, 0 },
99 .statusIconOffset = { -20, 40 },
100 .statusTextOffset = { 10, 30 },
101};
102
103API_CALLABLE(N(IsHitEightTimes)) {
104 script->varTable[0] = 0;
106 script->varTable[0] = 1;
107 }
108
109 return ApiStatus_DONE2;
110}
111
112EvtScript N(EVS_Init) = {
113 Call(BindTakeTurn, ACTOR_SELF, Ref(N(EVS_TakeTurn)))
114 Call(BindIdle, ACTOR_SELF, Ref(N(EVS_Idle)))
115 Call(BindHandleEvent, ACTOR_SELF, Ref(N(EVS_HandleEvent)))
116 Call(SetActorVar, ACTOR_SELF, AVAR_SpawnedBump, FALSE)
117 Call(N(IsHitEightTimes))
118 IfEq(LVar0, 0)
120 Call(SetPartFlagBits, ACTOR_SELF, PRT_MAIN, ACTOR_PART_FLAG_NO_TARGET, TRUE)
121 EndIf
122 Return
123 End
124};
125
126EvtScript N(EVS_Idle) = {
127 Label(0)
128 Wait(1)
129 Goto(0)
130 Return
131 End
132};
133
134EvtScript N(EVS_HandleEvent) = {
135 Call(UseIdleAnimation, ACTOR_SELF, FALSE)
136 Call(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE)
137 Call(GetLastEvent, ACTOR_SELF, LVar0)
140 Call(PlaySoundAtActor, ACTOR_SELF, SOUND_HIT_WHACKA)
141 SetConst(LVar0, PRT_MAIN)
142 SetConst(LVar1, ANIM_Whacka_Idle)
145 SetConst(LVar0, PRT_MAIN)
146 SetConst(LVar1, ANIM_Whacka_Hurt)
147 ExecWait(N(EVS_MakeWhackaBump))
149 Call(RandInt, 100, LVar0)
150 IfLe(LVar0, 100)
151 ExecWait(N(EVS_Death))
152 Return
153 EndIf
155 SetConst(LVar0, PRT_MAIN)
156 SetConst(LVar1, ANIM_Whacka_Idle)
157 SetConst(LVar2, ANIM_Whacka_Idle)
158 ExecWait(N(EVS_MakeWhackaBump))
160 Call(RandInt, 100, LVar0)
161 IfLe(LVar0, 100)
162 ExecWait(N(EVS_Death))
163 Return
164 EndIf
166 SetConst(LVar0, PRT_MAIN)
167 SetConst(LVar1, ANIM_Whacka_Idle)
168 SetConst(LVar2, ANIM_Whacka_Idle)
169 ExecWait(N(EVS_MakeWhackaBump))
171 IfGe(100, 100)
172 ExecWait(N(EVS_Death))
173 Return
174 Else
175 SetConst(LVar0, PRT_MAIN)
176 SetConst(LVar1, ANIM_Whacka_Idle)
178 Return
179 EndIf
181 SetConst(LVar0, PRT_MAIN)
182 SetConst(LVar1, ANIM_Whacka_Idle)
184 Call(RandInt, 100, LVar0)
185 IfLe(LVar0, 100)
186 ExecWait(N(EVS_Death))
187 Return
188 EndIf
190 SetConst(LVar0, PRT_MAIN)
191 SetConst(LVar1, ANIM_Whacka_Idle)
193 IfGe(100, 100)
194 ExecWait(N(EVS_Death))
195 Return
196 Else
197 SetConst(LVar0, PRT_MAIN)
198 SetConst(LVar1, ANIM_Whacka_Idle)
200 Return
201 EndIf
203 SetConst(LVar0, PRT_MAIN)
204 SetConst(LVar1, ANIM_Whacka_Idle)
206 SetConst(LVar0, PRT_MAIN)
207 SetConst(LVar1, ANIM_Whacka_Idle)
209 SetConst(LVar0, PRT_MAIN)
210 SetConst(LVar1, ANIM_Whacka_Idle)
213 SetConst(LVar0, PRT_MAIN)
214 SetConst(LVar1, ANIM_Whacka_Idle)
216 SetConst(LVar0, PRT_MAIN)
217 SetConst(LVar1, ANIM_Whacka_Idle)
219 Return
221 SetConst(LVar0, PRT_MAIN)
222 SetConst(LVar1, ANIM_Whacka_Idle)
225 SetConst(LVar0, PRT_MAIN)
226 SetConst(LVar1, ANIM_Whacka_Idle)
228 Call(RandInt, 100, LVar0)
229 IfLe(LVar0, 100)
230 ExecWait(N(EVS_Death))
231 Return
232 EndIf
234 SetConst(LVar0, PRT_MAIN)
235 SetConst(LVar1, ANIM_Whacka_Idle)
237 Call(RandInt, 100, LVar0)
238 IfLe(LVar0, 100)
239 ExecWait(N(EVS_Death))
240 Return
241 EndIf
243 SetConst(LVar0, PRT_MAIN)
244 SetConst(LVar1, ANIM_Whacka_Hurt)
245 ExecWait(N(EVS_MakeWhackaBump))
247 Wait(10)
248 IfGe(100, 100)
249 ExecWait(N(EVS_Death))
250 Return
251 Else
252 SetConst(LVar0, PRT_MAIN)
253 SetConst(LVar1, ANIM_Whacka_Idle)
255 Return
256 EndIf
258 SetConst(LVar0, PRT_MAIN)
259 SetConst(LVar1, ANIM_Whacka_Idle)
262 SetConst(LVar0, PRT_MAIN)
263 SetConst(LVar1, ANIM_Whacka_Idle)
264 SetConst(LVar2, ANIM_Whacka_Idle)
266 Return
268 SetConst(LVar0, PRT_MAIN)
269 SetConst(LVar1, ANIM_Whacka_Idle)
272 SetConst(LVar0, PRT_MAIN)
273 SetConst(LVar1, ANIM_Whacka_Idle)
275 Return
278 Call(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE)
279 Call(UseIdleAnimation, ACTOR_SELF, TRUE)
280 Return
281 End
282};
283
284EvtScript N(EVS_TakeTurn) = {
285 Call(RandInt, 100, LVar0)
286 IfLe(LVar0, 100)
287 ExecWait(N(EVS_Death))
288 Return
289 EndIf
290 Return
291 End
292};
293
294EvtScript N(EVS_MakeWhackaBump) = {
295 Call(SetActorVar, ACTOR_SELF, AVAR_SpawnedBump, TRUE)
296 Call(PlaySoundAtActor, ACTOR_SELF, SOUND_HIT_WHACKA)
297 Thread
298 Wait(15)
299 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_Whacka_Idle)
300 Call(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2)
301 Add(LVar0, 5)
302 Add(LVar1, 20)
303 Add(LVar2, 10)
306 Return
307 End
308};
309
310EvtScript N(EVS_Death) = {
311 Call(UseIdleAnimation, ACTOR_SELF, FALSE)
312 Call(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE)
313 Call(PlaySoundAtActor, ACTOR_SELF, SOUND_BURROW_DIG)
314 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_Whacka_Burrow)
315 Wait(40)
316 Call(GetActorVar, ACTOR_SELF, AVAR_SpawnedBump, LVar0)
317 IfNe(LVar0, FALSE)
318 Call(SetBattleFlagBits2, BS_FLAGS2_DROP_WHACKA_BUMP, TRUE)
319 EndIf
320 Call(SetPartFlagBits, ACTOR_SELF, PRT_MAIN, ACTOR_PART_FLAG_NO_TARGET, TRUE)
322 Call(RemoveActor, ACTOR_SELF)
323 Return
324 End
325};
Bytecode EvtScript[]
@ ELEMENT_END
Definition enums.h:2114
@ ELEMENT_NORMAL
Definition enums.h:2115
@ ACTOR_EVENT_FLAGS_NONE
Definition enums.h:3370
@ ITEM_SPAWN_MODE_FALL_SPAWN_ALWAYS
Definition enums.h:2303
@ BS_FLAGS2_DROP_WHACKA_BUMP
Definition enums.h:3622
@ 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
@ IDLE_SCRIPT_ENABLE
Definition enums.h:6408
@ IDLE_SCRIPT_DISABLE
Definition enums.h:6407
@ SOUND_BURROW_DIG
Definition enums.h:1118
@ SOUND_HIT_WHACKA
Definition enums.h:1412
@ ACTOR_SELF
Definition enums.h:2084
@ ACTOR_FLAG_INVISIBLE
Actor is not rendered.
Definition enums.h:3324
@ ACTOR_FLAG_NO_SHADOW
Hide shadow.
Definition enums.h:3325
@ ACTOR_FLAG_NO_HEALTH_BAR
Definition enums.h:3337
@ 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
@ EVENT_HIT
Definition enums.h:2132
@ 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_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_NO_TARGET
Cannot be targeted.
Definition enums.h:3360
#define ApiStatus_DONE2
Definition evt.h:118
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
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_NoDamageHit
@ GB_IWA00_Whacka_HitCount
ApiStatus MakeItemEntity(Evt *script, b32 isInitialCall)
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 IfGe(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR >= RVAR.
Definition macros.h:284
#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 IfNe(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR != RVAR.
Definition macros.h:272
#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 Goto(LABEL_ID)
Moves execution to the given label.
Definition macros.h:232
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define Label(LABEL_ID)
Marks this point in the script as a Goto target.
Definition macros.h:227
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:298
#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 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 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 LVar2
Definition macros.h:150
#define LVar1
Definition macros.h:149
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#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 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