Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
demo_power_bounce.c
Go to the documentation of this file.
1#include "common.h"
2#include "script_api/battle.h"
4#include "battle/battle.h"
5#include "sprite/player.h"
6
7#define NAMESPACE battle_move_demo_power_bounce
8
10
11s32 N(DifficultyTable)[] = {
12 7, 6, 5, 4, 3, 2, 1, 0
13};
14
15s32 N(BaseHitChance) = 200;
16
17API_CALLABLE(N(GetHitChance)) {
18 Actor* enemyTargetActor = get_actor(get_actor(script->owner1.enemyID)->targetActorID);
19 u32 enemyTargetPowerBounceChance;
20
21 script->varTable[0] = 99;
22
23 enemyTargetPowerBounceChance = enemyTargetActor->actorBlueprint->powerBounceChance;
24
26 enemyTargetPowerBounceChance += 7;
27 }
28
29 N(BaseHitChance) *= enemyTargetPowerBounceChance;
30 N(BaseHitChance) /= 100;
31
32 if (N(BaseHitChance) < rand_int(100)) {
33 script->varTable[0] = 0;
34 }
35
36 return ApiStatus_DONE2;
37}
38
39extern EvtScript N(EVS_UseMove_Normal);
40extern EvtScript N(EVS_UseMove_Super);
41extern EvtScript N(EVS_UseMove_Ultra);
42
43EvtScript N(EVS_UseMove) = {
44 Set(LFlagA, FALSE)
45 Call(ShowActionHud, TRUE)
46 Call(SetBattleFlagBits, BS_FLAGS1_AUTO_SUCCEED_ACTION, TRUE)
47 Call(GetMenuSelection, LVar0, LVar1, LVar2)
49 CaseEq(0)
50 Set(LVarC, 1)
51 ExecWait(N(EVS_UseMove_Normal))
52 CaseEq(1)
53 Set(LVarC, 2)
54 ExecWait(N(EVS_UseMove_Super))
55 CaseEq(2)
56 Set(LVarC, 3)
57 ExecWait(N(EVS_UseMove_Ultra))
59 Return
60 End
61};
62
63EvtScript N(EVS_UseMove_Normal) = {
64 Call(LoadActionCommand, ACTION_COMMAND_JUMP)
65 Call(action_command_jump_init)
66 Call(SetActionDifficultyTable, Ref(N(DifficultyTable)))
67 ExecWait(N(EVS_JumpSupport_Approach))
68 ExecWait(N(EVS_JumpSupport_CalcJumpTime))
69 Call(action_command_jump_start, LVarA, 1)
70 Call(UseBattleCamPreset, BTL_CAM_PLAYER_JUMP_MIDAIR)
71 Call(SetGoalToTarget, ACTOR_PLAYER)
72 Call(SetJumpAnimations, ACTOR_PLAYER, 0, ANIM_Mario1_Jump, ANIM_Mario1_Fall, ANIM_MarioB1_Stomp)
73 Call(PlayerBasicJumpToGoal, LVarA, PLAYER_BASIC_JUMP_0)
74 Call(PlayerTestEnemy, LVar0, DAMAGE_TYPE_JUMP, 0, 0, 1, 0)
76 ExecWait(N(EVS_JumpSupport_Miss))
77 Return
78 EndIf
79 Wait(1)
80 Call(GetPlayerActionSuccess, LVar0)
82 CaseGt(FALSE)
92 ExecWait(N(EVS_JumpSupport_NoFollowUp))
93 Return
100 Call(UseBattleCamPreset, BTL_CAM_PLAYER_PRE_JUMP_FINISH)
101 Wait(5)
102 Call(SetGoalToTarget, ACTOR_PLAYER)
103 Call(UseBattleCamPreset, BTL_CAM_PLAYER_JUMP_FINISH)
105 Call(GetActionResult, LVarE)
106 Set(LVarD, 0)
107 Set(LVarF, 0)
108 Set(LFlag0, FALSE)
109 Label(10)
111 Call(UseBattleCamPreset, BTL_CAM_PLAYER_PRE_JUMP_FINISH)
112 Wait(5)
113 Call(SetGoalToTarget, ACTOR_PLAYER)
114 Call(UseBattleCamPreset, BTL_CAM_PLAYER_JUMP_FINISH)
116 Call(CloseActionCommandInfo)
117 Call(SetActionDifficultyTable, Ref(N(DifficultyTable)))
118 Call(LoadActionCommand, ACTION_COMMAND_JUMP)
119 Call(action_command_jump_init)
120 Set(LVarA, 24)
122 CaseEq(0)
123 Call(action_command_jump_start, LVarA, 1)
124 CaseEq(1)
125 Call(action_command_jump_start, LVarA, 2)
126 CaseEq(2)
127 Call(action_command_jump_start, LVarA, 3)
128 CaseEq(3)
129 Call(action_command_jump_start, LVarA, 4)
131 Call(action_command_jump_start, LVarA, 5)
133 Sub(LVarD, 1)
134 Call(SetJumpAnimations, ACTOR_PLAYER, 0, ANIM_Mario1_Jump, ANIM_Mario1_Fall, ANIM_Mario1_SpinFall)
135 Call(SetGoalToTarget, ACTOR_PLAYER)
136 IfEq(LVarF, 0)
137 Call(PlayerBasicJumpToGoal, 24, PLAYER_BASIC_JUMP_3)
138 Else
139 Call(PlayerBasicJumpToGoal, 24, PLAYER_BASIC_JUMP_4)
140 EndIf
141 Call(GetCommandAutoSuccess, LVar1)
142 IfEq(LVar1, 1)
143 IfGe(LVarF, 3)
144 Set(LFlag0, TRUE)
145 EndIf
146 EndIf
147 Call(N(GetHitChance))
149 Set(LFlag0, TRUE)
150 EndIf
151 Wait(1)
152 Call(GetPlayerActionSuccess, LVar0)
154 CaseGt(FALSE)
155 IfEq(LFlag0, FALSE)
157 Call(PlayerPowerBounceEnemy, LVar0, DAMAGE_TYPE_JUMP | DAMAGE_TYPE_POWER_BOUNCE, 0, 0, LVarC, LVarD, 64)
158 Else
160 Call(PlayerPowerBounceEnemy, LVar0, DAMAGE_TYPE_JUMP | DAMAGE_TYPE_POWER_BOUNCE, 0, 0, LVarC, LVarD, 224)
161 EndIf
164 Call(PlayerPowerBounceEnemy, LVar0, DAMAGE_TYPE_JUMP | DAMAGE_TYPE_POWER_BOUNCE, 0, 0, LVarC, LVarD, 32)
167 CaseEq(0)
168 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_JUMP_COMBO_1)
169 CaseEq(1)
170 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_JUMP_COMBO_2)
171 CaseEq(2)
172 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_JUMP_COMBO_3)
173 CaseEq(3)
174 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_JUMP_COMBO_4)
176 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_JUMP_COMBO_4)
178 Call(SetActionResult, LVarE)
182 ExecWait(N(EVS_JumpSupport_NoFollowUp))
183 Return
187 IfEq(LFlag0, TRUE)
188 ExecWait(N(EVS_JumpSupport_Rebound))
189 Return
190 EndIf
193 Add(LVarF, 1)
194 Goto(10)
195 Return
196 End
197};
198
199EvtScript N(EVS_UseMove_Super) = {
200 Call(LoadActionCommand, ACTION_COMMAND_JUMP)
201 Call(action_command_jump_init)
202 Call(SetActionDifficultyTable, Ref(N(DifficultyTable)))
203 ExecWait(N(EVS_JumpSupport_Approach))
204 ExecWait(N(EVS_JumpSupport_CalcJumpTime))
205 Call(action_command_jump_start, LVarA, 1)
206 Call(UseBattleCamPreset, BTL_CAM_PLAYER_JUMP_MIDAIR)
207 Call(SetGoalToTarget, ACTOR_PLAYER)
208 Call(SetJumpAnimations, ACTOR_PLAYER, 0, ANIM_Mario1_Jump, ANIM_Mario1_Fall, ANIM_MarioB1_Stomp)
209 Call(PlayerBasicJumpToGoal, LVarA, PLAYER_BASIC_JUMP_0)
210 Call(PlayerTestEnemy, LVar0, DAMAGE_TYPE_JUMP, 0, 0, 1, 0)
212 ExecWait(N(EVS_JumpSupport_Miss))
213 Return
214 EndIf
215 Wait(1)
216 Call(GetPlayerActionSuccess, LVar0)
218 CaseGt(FALSE)
228 ExecWait(N(EVS_JumpSupport_NoFollowUp))
229 Return
235 Call(GetActionResult, LVarE)
236 Set(LVarD, 0)
237 Set(LVarF, 0)
238 Set(LFlag0, FALSE)
239 Label(10)
241 Call(UseBattleCamPreset, BTL_CAM_PLAYER_PRE_JUMP_FINISH)
242 Wait(5)
243 Call(SetGoalToTarget, ACTOR_PLAYER)
244 Call(UseBattleCamPreset, BTL_CAM_PLAYER_JUMP_FINISH)
246 Call(CloseActionCommandInfo)
247 Call(SetActionDifficultyTable, Ref(N(DifficultyTable)))
248 Call(LoadActionCommand, ACTION_COMMAND_JUMP)
249 Call(action_command_jump_init)
250 Set(LVarA, 37)
252 CaseEq(0)
253 Call(action_command_jump_start, LVarA, 1)
254 CaseEq(1)
255 Call(action_command_jump_start, LVarA, 2)
256 CaseEq(2)
257 Call(action_command_jump_start, LVarA, 3)
258 CaseEq(3)
259 Call(action_command_jump_start, LVarA, 4)
261 Call(action_command_jump_start, LVarA, 5)
263 Sub(LVarD, 1)
264 Call(SetGoalToTarget, ACTOR_PLAYER)
265 Call(SetJumpAnimations, ACTOR_PLAYER, 0, ANIM_Mario1_Jump, ANIM_Mario1_Sit, ANIM_Mario1_SpinJump)
266 Call(EnablePlayerBlur, ACTOR_BLUR_ENABLE)
267 IfEq(LVarF, 0)
268 Call(PlayerSuperJumpToGoal, 20, PLAYER_SUPER_JUMP_3)
269 Wait(7)
270 Call(PlayerSuperJumpToGoal, 3, PLAYER_SUPER_JUMP_6)
271 Else
272 Call(PlayerSuperJumpToGoal, 20, PLAYER_SUPER_JUMP_4)
273 Wait(7)
274 Call(PlayerSuperJumpToGoal, 3, PLAYER_SUPER_JUMP_5)
275 EndIf
276 Call(EnablePlayerBlur, ACTOR_BLUR_DISABLE)
277 Call(GetCommandAutoSuccess, LVar1)
278 IfEq(LVar1, 1)
279 IfGt(LVarF, 3)
280 Set(LFlag0, TRUE)
281 EndIf
282 EndIf
283 Call(N(GetHitChance))
285 Set(LFlag0, TRUE)
286 EndIf
287 Wait(1)
288 Call(GetPlayerActionSuccess, LVar0)
290 CaseGt(FALSE)
291 IfEq(LFlag0, FALSE)
293 Call(PlayerPowerBounceEnemy, LVar0, DAMAGE_TYPE_JUMP | DAMAGE_TYPE_POWER_BOUNCE, 0, 0, LVarC, LVarD, 64)
294 Else
296 Call(PlayerPowerBounceEnemy, LVar0, DAMAGE_TYPE_JUMP | DAMAGE_TYPE_POWER_BOUNCE, 0, 0, LVarC, LVarD, 224)
297 EndIf
300 Call(PlayerPowerBounceEnemy, LVar0, DAMAGE_TYPE_JUMP | DAMAGE_TYPE_POWER_BOUNCE, 0, 0, LVarC, LVarD, 32)
303 CaseEq(0)
304 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_JUMP_COMBO_1)
305 CaseEq(1)
306 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_JUMP_COMBO_2)
307 CaseEq(2)
308 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_JUMP_COMBO_3)
309 CaseEq(3)
310 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_JUMP_COMBO_4)
312 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_JUMP_COMBO_4)
314 Call(SetActionResult, LVarE)
318 ExecWait(N(EVS_JumpSupport_NoFollowUp))
319 Return
323 IfEq(LFlag0, TRUE)
324 ExecWait(N(EVS_JumpSupport_Rebound))
325 Return
326 EndIf
329 Add(LVarF, 1)
330 Goto(10)
331 Return
332 End
333};
334
335EvtScript N(EVS_UseMove_Ultra) = {
336 Call(LoadActionCommand, ACTION_COMMAND_JUMP)
337 Call(action_command_jump_init)
338 Call(SetActionDifficultyTable, Ref(N(DifficultyTable)))
339 ExecWait(N(EVS_JumpSupport_Approach))
340 ExecWait(N(EVS_JumpSupport_CalcJumpTime))
341 Call(action_command_jump_start, LVarA, 1)
342 Call(UseBattleCamPreset, BTL_CAM_PLAYER_JUMP_MIDAIR)
343 Call(SetGoalToTarget, ACTOR_PLAYER)
344 Call(SetJumpAnimations, ACTOR_PLAYER, 0, ANIM_Mario1_Jump, ANIM_Mario1_Fall, ANIM_MarioB1_Stomp)
345 Call(PlayerBasicJumpToGoal, LVarA, PLAYER_BASIC_JUMP_0)
346 Call(PlayerTestEnemy, LVar0, DAMAGE_TYPE_JUMP, 0, 0, 1, 0)
348 ExecWait(N(EVS_JumpSupport_Miss))
349 Return
350 EndIf
351 Wait(1)
352 Call(GetPlayerActionSuccess, LVar0)
354 CaseGt(FALSE)
364 ExecWait(N(EVS_JumpSupport_NoFollowUp))
365 Return
371 Call(GetActionResult, LVarE)
372 Set(LVarD, 0)
373 Set(LVarF, 0)
374 Set(LFlag0, FALSE)
375 Label(10)
377 Call(UseBattleCamPreset, BTL_CAM_PLAYER_PRE_ULTRA_JUMP_FINISH)
378 Wait(5)
379 Call(SetGoalToTarget, ACTOR_PLAYER)
380 Call(UseBattleCamPreset, BTL_CAM_PLAYER_JUMP_FINISH)
382 Call(CloseActionCommandInfo)
383 Call(SetActionDifficultyTable, Ref(N(DifficultyTable)))
384 Call(LoadActionCommand, ACTION_COMMAND_JUMP)
385 Call(action_command_jump_init)
386 Set(LVarA, 25)
388 CaseEq(0)
389 Call(action_command_jump_start, LVarA, 1)
390 CaseEq(1)
391 Call(action_command_jump_start, LVarA, 2)
392 CaseEq(2)
393 Call(action_command_jump_start, LVarA, 3)
394 CaseEq(3)
395 Call(action_command_jump_start, LVarA, 4)
397 Call(action_command_jump_start, LVarA, 5)
399 Sub(LVarD, 1)
400 Call(SetGoalToTarget, ACTOR_PLAYER)
401 Call(EnablePlayerBlur, ACTOR_BLUR_ENABLE)
402 Call(SetJumpAnimations, ACTOR_PLAYER, 0, ANIM_Mario1_Jump, ANIM_Mario1_Jump, ANIM_Mario1_SpinFall)
403 IfEq(LVarF, 0)
404 Call(PlayerUltraJumpToGoal, 25, PLAYER_ULTRA_JUMP_2)
405 Else
406 Call(PlayerUltraJumpToGoal, 25, PLAYER_ULTRA_JUMP_4)
407 EndIf
408 Call(EnablePlayerBlur, ACTOR_BLUR_DISABLE)
409 Call(GetCommandAutoSuccess, LVar1)
410 IfEq(LVar1, 1)
411 IfGt(LVarF, 3)
412 Set(LFlag0, TRUE)
413 EndIf
414 EndIf
415 Call(N(GetHitChance))
417 Set(LFlag0, TRUE)
418 EndIf
419 Wait(1)
420 Call(GetPlayerActionSuccess, LVar0)
422 CaseGt(FALSE)
423 IfEq(LFlag0, FALSE)
425 Call(PlayerPowerBounceEnemy, LVar0, DAMAGE_TYPE_JUMP | DAMAGE_TYPE_POWER_BOUNCE, 0, 0, LVarC, LVarD, 64)
426 Else
428 Call(PlayerPowerBounceEnemy, LVar0, DAMAGE_TYPE_JUMP | DAMAGE_TYPE_POWER_BOUNCE, 0, 0, LVarC, LVarD, 224)
429 EndIf
432 Call(PlayerPowerBounceEnemy, LVar0, DAMAGE_TYPE_JUMP | DAMAGE_TYPE_POWER_BOUNCE, 0, 0, LVarC, LVarD, 32)
435 CaseEq(0)
436 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_JUMP_COMBO_1)
437 CaseEq(1)
438 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_JUMP_COMBO_2)
439 CaseEq(2)
440 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_JUMP_COMBO_3)
441 CaseEq(3)
442 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_JUMP_COMBO_4)
444 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_JUMP_COMBO_4)
446 Call(SetActionResult, LVarE)
450 ExecWait(N(EVS_JumpSupport_NoFollowUp))
451 Return
455 IfEq(LFlag0, TRUE)
456 ExecWait(N(EVS_JumpSupport_Rebound))
457 Return
458 EndIf
461 Add(LVarF, 1)
462 Goto(10)
463 Return
464 End
465};
struct ActorBlueprint * actorBlueprint
s16 targetActorID
Bytecode EvtScript[]
#define rand_int
@ ACTION_COMMAND_JUMP
Definition enums.h:3473
@ ACTOR_SOUND_HURT
Definition enums.h:2037
@ BS_FLAGS1_NICE_HIT
Definition enums.h:3576
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3575
@ BS_FLAGS1_AUTO_SUCCEED_ACTION
Definition enums.h:3581
@ BS_FLAGS1_INCLUDE_POWER_UPS
Definition enums.h:3571
@ PLAYER_ULTRA_JUMP_2
Definition enums.h:4315
@ PLAYER_ULTRA_JUMP_4
Definition enums.h:4317
@ PLAYER_SUPER_JUMP_3
Definition enums.h:4306
@ PLAYER_SUPER_JUMP_4
Definition enums.h:4307
@ PLAYER_SUPER_JUMP_5
Definition enums.h:4308
@ PLAYER_SUPER_JUMP_6
Definition enums.h:4309
@ HIT_RESULT_NO_DAMAGE
Definition enums.h:1952
@ HIT_RESULT_HIT
Definition enums.h:1950
@ HIT_RESULT_NICE_NO_DAMAGE
Definition enums.h:1953
@ HIT_RESULT_NICE
Definition enums.h:1951
@ HIT_RESULT_MISS
Definition enums.h:1956
@ BTL_CAM_PLAYER_PRE_ULTRA_JUMP_FINISH
Definition enums.h:4850
@ BTL_CAM_PLAYER_PRE_JUMP_FINISH
Definition enums.h:4849
@ BTL_CAM_PLAYER_JUMP_FINISH
Definition enums.h:4857
@ BTL_CAM_PLAYER_JUMP_MIDAIR
Definition enums.h:4856
@ PLAYER_BASIC_JUMP_3
Definition enums.h:4298
@ PLAYER_BASIC_JUMP_4
Definition enums.h:4299
@ PLAYER_BASIC_JUMP_0
Definition enums.h:4295
@ ABILITY_DODGE_MASTER
Definition enums.h:436
@ SOUND_ACTOR_JUMPED_2
Definition enums.h:778
@ SOUND_JUMP_COMBO_1
Definition enums.h:954
@ SOUND_ACTOR_JUMPED_1
Definition enums.h:777
@ SOUND_NONE
Definition enums.h:547
@ SOUND_JUMP_COMBO_4
Definition enums.h:957
@ SOUND_JUMP_COMBO_3
Definition enums.h:956
@ SOUND_ACTOR_JUMPED_3
Definition enums.h:779
@ SOUND_JUMP_COMBO_2
Definition enums.h:955
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_BLUR_ENABLE
Definition enums.h:6414
@ ACTOR_BLUR_DISABLE
Definition enums.h:6413
@ DAMAGE_TYPE_POWER_BOUNCE
Definition enums.h:2870
@ DAMAGE_TYPE_JUMP
Definition enums.h:2858
#define ApiStatus_DONE2
Definition evt.h:118
s32 is_ability_active(s32 arg0)
Definition inventory.c:1725
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
#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 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 LVarF
Definition macros.h:163
#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 LFlagA
Definition macros.h:177
#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 LVarC
Definition macros.h:160
#define IfGt(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR <= RVAR.
Definition macros.h:278
#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 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 LVar2
Definition macros.h:150
#define LVar1
Definition macros.h:149
#define LFlag0
Definition macros.h:167
#define LVarA
Definition macros.h:158
#define LVarD
Definition macros.h:161
#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 ChildThread
Marks the start of a child thread block.
Definition macros.h:560
#define CaseGt(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:328
#define LVarE
Definition macros.h:162
#define LVar0
Definition macros.h:148
#define Return
Kills the current EVT thread.
Definition macros.h:217
u8 powerBounceChance
Definition battle.h:146