Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
piranha_plant.inc.c
Go to the documentation of this file.
1#include "battle/battle.h"
2#include "script_api/battle.h"
3#include "sprite/npc/SmallPiranha.h"
4
5#define NAMESPACE A(piranha_plant)
6
7extern EvtScript N(EVS_Init);
8extern EvtScript N(EVS_Idle);
9extern EvtScript N(EVS_TakeTurn);
10extern EvtScript N(EVS_HandleEvent);
11
12enum N(ActorPartIDs) {
13 PRT_MAIN = 1,
14};
15
16enum N(ActorParams) {
17 DMG_BITE = 3,
18};
19
20s32 N(DefaultAnims)[] = {
21 STATUS_KEY_NORMAL, ANIM_SmallPiranha_Anim01,
22 STATUS_KEY_STONE, ANIM_SmallPiranha_Anim00,
23 STATUS_KEY_SLEEP, ANIM_SmallPiranha_Anim00,
24 STATUS_KEY_POISON, ANIM_SmallPiranha_Anim01,
25 STATUS_KEY_STOP, ANIM_SmallPiranha_Anim00,
26 STATUS_KEY_STATIC, ANIM_SmallPiranha_Anim01,
27 STATUS_KEY_PARALYZE, ANIM_SmallPiranha_Anim00,
28 STATUS_KEY_DIZZY, ANIM_SmallPiranha_Anim01,
29 STATUS_KEY_FEAR, ANIM_SmallPiranha_Anim01,
31};
32
33s32 N(UnusedAnims1)[] = {
34 STATUS_KEY_NORMAL, ANIM_SmallPiranha_Anim01,
36};
37
38s32 N(UnusedAnims2)[] = {
39 STATUS_KEY_NORMAL, ANIM_SmallPiranha_Anim06,
41};
42
43s32 N(DefenseTable)[] = {
46};
47
48s32 N(StatusTable)[] = {
71};
72
73ActorPartBlueprint N(ActorParts)[] = {
74 {
76 .index = PRT_MAIN,
77 .posOffset = { 0, 0, 0 },
78 .targetOffset = { 0, 35 },
79 .opacity = 255,
80 .idleAnimations = N(DefaultAnims),
81 .defenseTable = N(DefenseTable),
82 .eventFlags = ACTOR_EVENT_FLAG_SPIKY_TOP,
83 .elementImmunityFlags = 0,
84 .projectileTargetOffset = { 0, -10 },
85 },
86};
87
88ActorBlueprint NAMESPACE = {
89 .flags = 0,
90 .type = ACTOR_TYPE_PIRANHA_PLANT,
91 .level = ACTOR_LEVEL_PIRANHA_PLANT,
92 .maxHP = 5,
93 .partCount = ARRAY_COUNT(N(ActorParts)),
94 .partsData = N(ActorParts),
95 .initScript = &N(EVS_Init),
96 .statusTable = N(StatusTable),
97 .escapeChance = 70,
98 .airLiftChance = 20,
99 .hurricaneChance = 20,
100 .spookChance = 40,
101 .upAndAwayChance = 95,
102 .spinSmashReq = 0,
103 .powerBounceChance = 90,
104 .coinReward = 1,
105 .size = { 38, 38 },
106 .healthBarOffset = { 0, 0 },
107 .statusIconOffset = { -7, 33 },
108 .statusTextOffset = { 10, 33 },
109};
110
111EvtScript N(EVS_Init) = {
112 Call(BindTakeTurn, ACTOR_SELF, Ref(N(EVS_TakeTurn)))
113 Call(BindIdle, ACTOR_SELF, Ref(N(EVS_Idle)))
114 Call(BindHandleEvent, ACTOR_SELF, Ref(N(EVS_HandleEvent)))
115 Return
116 End
117};
118
119EvtScript N(EVS_Idle) = {
120 Return
121 End
122};
123
124EvtScript N(EVS_ReturnHome) = {
125 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
126 Call(MoveBattleCamOver, 20)
127 Call(SetActorFlagBits, ACTOR_SELF, ACTOR_FLAG_NO_SHADOW, TRUE)
128 Call(PlaySoundAtActor, ACTOR_SELF, SOUND_BURROW_DIG)
129 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_SmallPiranha_Anim04)
130 Wait(10)
131 Call(SetGoalToHome, ACTOR_SELF)
132 Call(GetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2)
133 Call(SetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2)
134 Call(PlaySoundAtActor, ACTOR_SELF, SOUND_BURROW_SURFACE)
135 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_SmallPiranha_Anim03)
136 Wait(10)
137 Call(SetActorFlagBits, ACTOR_SELF, ACTOR_FLAG_NO_SHADOW, FALSE)
138 Return
139 End
140};
141
142EvtScript N(EVS_HandleEvent) = {
143 Call(UseIdleAnimation, ACTOR_SELF, FALSE)
144 Call(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE)
145 Call(GetLastEvent, ACTOR_SELF, LVar0)
149 SetConst(LVar0, PRT_MAIN)
150 SetConst(LVar1, ANIM_SmallPiranha_Anim09)
154 SetConst(LVar0, PRT_MAIN)
155 SetConst(LVar1, ANIM_SmallPiranha_Anim0A)
156 SetConst(LVar2, ANIM_SmallPiranha_Anim0B)
159 SetConst(LVar0, PRT_MAIN)
160 SetConst(LVar1, ANIM_SmallPiranha_Anim0A)
161 SetConst(LVar2, ANIM_SmallPiranha_Anim0B)
163 SetConst(LVar0, PRT_MAIN)
164 SetConst(LVar1, ANIM_SmallPiranha_Anim0B)
166 Return
168 SetConst(LVar0, PRT_MAIN)
169 SetConst(LVar1, ANIM_SmallPiranha_Anim09)
172 SetConst(LVar0, PRT_MAIN)
173 SetConst(LVar1, ANIM_SmallPiranha_Anim09)
175 SetConst(LVar0, PRT_MAIN)
176 SetConst(LVar1, ANIM_SmallPiranha_Anim09)
178 Return
180 SetConst(LVar0, PRT_MAIN)
181 SetConst(LVar1, ANIM_SmallPiranha_Anim09)
183 Call(SetActorSpeed, ACTOR_SELF, Float(4.0))
184 ExecWait(N(EVS_ReturnHome))
186 SetConst(LVar0, PRT_MAIN)
187 SetConst(LVar1, ANIM_SmallPiranha_Anim09)
189 SetConst(LVar0, PRT_MAIN)
190 SetConst(LVar1, ANIM_SmallPiranha_Anim09)
192 Return
196 SetConst(LVar0, PRT_MAIN)
197 SetConst(LVar1, ANIM_SmallPiranha_Anim01)
201 Thread
202 Wait(10)
203 Call(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2)
204 Call(GetStatusFlags, ACTOR_SELF, LVar3)
206 Add(LVar0, 0)
207 Add(LVar1, 14)
208 Else
209 Add(LVar0, 0)
210 Add(LVar1, 35)
211 EndIf
212 PlayEffect(EFFECT_LENS_FLARE, 0, LVar0, LVar1, LVar2, 20, 0)
213 Wait(20)
215 Loop(40)
216 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_SmallPiranha_Anim01)
217 Wait(1)
218 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_SmallPiranha_Anim06)
219 Wait(1)
220 EndLoop
221 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_SmallPiranha_Anim01)
223 SetConst(LVar0, PRT_MAIN)
224 SetConst(LVar1, ANIM_SmallPiranha_Anim09)
226 Wait(10)
227 SetConst(LVar0, PRT_MAIN)
228 SetConst(LVar1, ANIM_SmallPiranha_Anim09)
230 Return
232 SetConst(LVar0, PRT_MAIN)
233 SetConst(LVar1, ANIM_SmallPiranha_Anim01)
236 SetConst(LVar0, PRT_MAIN)
237 SetConst(LVar1, ANIM_SmallPiranha_Anim09)
239 Call(PlaySoundAtActor, ACTOR_SELF, SOUND_BURROW_DIG)
240 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_SmallPiranha_Anim04)
241 Call(SetActorFlagBits, ACTOR_SELF, ACTOR_FLAG_NO_SHADOW, TRUE)
242 Wait(8)
243 Call(HideHealthBar, ACTOR_SELF)
244 Call(UseIdleAnimation, ACTOR_SELF, FALSE)
245 Call(RemoveActor, ACTOR_SELF)
246 Return
248 SetConst(LVar0, PRT_MAIN)
249 SetConst(LVar1, ANIM_SmallPiranha_Anim09)
252 SetConst(LVar0, PRT_MAIN)
253 SetConst(LVar1, ANIM_SmallPiranha_Anim09)
255 Return
258 Call(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE)
259 Call(UseIdleAnimation, ACTOR_SELF, TRUE)
260 Return
261 End
262};
263
264EvtScript N(EVS_TakeTurn) = {
265 Call(UseIdleAnimation, ACTOR_SELF, FALSE)
266 Call(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE)
267 Call(SetTargetActor, ACTOR_SELF, ACTOR_PLAYER)
268 Call(GetBattlePhase, LVar0)
270 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_SmallPiranha_Anim04)
271 Call(SetActorFlagBits, ACTOR_SELF, ACTOR_FLAG_NO_SHADOW, TRUE)
272 Call(UseBattleCamPreset, BTL_CAM_ENEMY_APPROACH)
273 Call(BattleCamTargetActor, ACTOR_SELF)
274 Call(SetBattleCamTargetingModes, BTL_CAM_YADJ_TARGET, BTL_CAM_XADJ_AVG, FALSE)
275 Call(MoveBattleCamOver, 1)
276 Call(SetGoalToTarget, ACTOR_SELF)
277 Call(GetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2)
278 Add(LVar0, 20)
279 Set(LVar1, 0)
280 Call(SetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2)
281 Wait(15)
282 Goto(123)
283 EndIf
284 Call(PlaySoundAtActor, ACTOR_SELF, SOUND_BURROW_DIG)
285 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_SmallPiranha_Anim04)
286 Call(SetActorFlagBits, ACTOR_SELF, ACTOR_FLAG_NO_SHADOW, TRUE)
287 Wait(8)
288 Call(UseBattleCamPreset, BTL_CAM_REPOSITION)
289 Call(SetGoalToTarget, ACTOR_SELF)
290 Call(GetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2)
291 Add(LVar0, 20)
292 Set(LVar1, 0)
293 Call(SetBattleCamTarget, LVar0, LVar1, LVar2)
294 Call(SetBattleCamDist, 350)
295 Call(SetBattleCamOffsetY, 45)
296 Call(SetBattleCamTargetingModes, BTL_CAM_YADJ_TARGET, BTL_CAM_XADJ_AVG, FALSE)
297 Call(MoveBattleCamOver, 20)
298 Call(SetGoalToTarget, ACTOR_SELF)
299 Call(GetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2)
300 Call(GetStatusFlags, ACTOR_SELF, LVar5)
302 Add(LVar0, 8)
303 Add(LVar0, -3)
304 Else
305 Add(LVar0, 20)
306 EndIf
307 Set(LVar1, 0)
308 Call(SetActorJumpGravity, ACTOR_SELF, Float(1.0))
309 Call(SetActorSounds, ACTOR_SELF, ACTOR_SOUND_JUMP, SOUND_NONE, 0)
310 Call(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2)
311 Call(JumpToGoal, ACTOR_SELF, 20, FALSE, FALSE, FALSE)
312 Label(123)
313 Call(PlaySoundAtActor, ACTOR_SELF, SOUND_BURROW_SURFACE)
314 Call(SetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2)
315 Call(SetActorFlagBits, ACTOR_SELF, ACTOR_FLAG_NO_SHADOW, FALSE)
316 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_SmallPiranha_Anim03)
317 Wait(8)
318 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_SmallPiranha_Anim05)
319 Call(EnemyTestTarget, ACTOR_SELF, LVar0, 0, 0, 1, BS_FLAGS1_INCLUDE_POWER_UPS)
323 Set(LVarA, LVar0)
324 Call(GetStatusFlags, ACTOR_SELF, LVar5)
326 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_SmallPiranha_Anim06)
327 Wait(2)
328 EndIf
329 Thread
330 Wait(6)
331 Call(PlaySoundAtActor, ACTOR_SELF, SOUND_PIRANHA_BITE)
333 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_SmallPiranha_Anim07)
334 Wait(10)
335 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_SmallPiranha_Anim08)
336 Wait(2)
338 Call(EnemyTestTarget, ACTOR_SELF, LVar0, DAMAGE_TYPE_TRIGGER_LUCKY, 0, 0, 0)
339 EndIf
340 Wait(15)
341 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
342 Call(YieldTurn)
343 Call(SetActorSpeed, ACTOR_SELF, Float(4.0))
344 ExecWait(N(EVS_ReturnHome))
345 Call(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE)
346 Call(UseIdleAnimation, ACTOR_SELF, TRUE)
347 Return
350 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_SmallPiranha_Anim06)
351 Wait(2)
352 Thread
353 Wait(6)
354 Call(PlaySoundAtActor, ACTOR_SELF, SOUND_PIRANHA_BITE)
356 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_SmallPiranha_Anim07)
357 Wait(10)
358 Wait(2)
359 Call(SetGoalToTarget, ACTOR_SELF)
360 Call(EnemyDamageTarget, ACTOR_SELF, LVar0, 0, 0, 0, DMG_BITE, BS_FLAGS1_TRIGGER_EVENTS)
364 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
365 Wait(2)
366 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_SmallPiranha_Anim08)
367 Wait(15)
368 Call(YieldTurn)
369 Call(SetActorSpeed, ACTOR_SELF, Float(6.0))
370 ExecWait(N(EVS_ReturnHome))
373 Call(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE)
374 Call(UseIdleAnimation, ACTOR_SELF, TRUE)
375 Return
376 End
377};
Bytecode EvtScript[]
@ BTL_CAM_XADJ_AVG
Definition enums.h:4900
@ ACTOR_SOUND_JUMP
Definition enums.h:2036
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3575
@ BS_FLAGS1_INCLUDE_POWER_UPS
Definition enums.h:3571
@ ELEMENT_END
Definition enums.h:2114
@ ELEMENT_NORMAL
Definition enums.h:2115
@ ACTOR_EVENT_FLAG_SPIKY_TOP
Player takes spike damage from jump attacks.
Definition enums.h:3373
@ 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:4824
@ BTL_CAM_REPOSITION
Definition enums.h:4841
@ BTL_CAM_ENEMY_APPROACH
Definition enums.h:4885
@ IDLE_SCRIPT_ENABLE
Definition enums.h:6408
@ IDLE_SCRIPT_DISABLE
Definition enums.h:6407
@ STATUS_FLAG_SHRINK
Definition enums.h:2819
@ SOUND_BURROW_SURFACE
Definition enums.h:1117
@ SOUND_NONE
Definition enums.h:547
@ SOUND_BURROW_DIG
Definition enums.h:1118
@ SOUND_PIRANHA_BITE
Definition enums.h:1508
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_SELF
Definition enums.h:2084
@ ACTOR_FLAG_NO_SHADOW
Hide shadow.
Definition enums.h:3325
@ BTL_CAM_YADJ_TARGET
Definition enums.h:4905
@ 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_SPIKE_TAUNT
Definition enums.h:2148
@ 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
@ DAMAGE_TYPE_TRIGGER_LUCKY
Definition enums.h:2881
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
#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 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 Goto(LABEL_ID)
Moves execution to the given label.
Definition macros.h:232
#define ARRAY_COUNT(arr)
Definition macros.h:40
#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 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 ExecWait(EVT_SOURCE)
Launches a new child thread.
Definition macros.h:475
#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 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 Loop(TIMES)
Marks the beginning of a loop.
Definition macros.h:245
#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