Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
dizzy_dial.c
Go to the documentation of this file.
1#include "common.h"
2#include "script_api/battle.h"
3
4#define NAMESPACE battle_item_dizzy_dial
5
6static s32 ScreenBlurWorkerID;
7
9
11 draw_prev_frame_buffer_at_screen_pos(0, 0, 320, 240, 160.0f);
12}
13
14API_CALLABLE(N(AnimateDizzyDialCameraFX)) {
15 Camera* camera = &gCameras[CAM_BATTLE];
16 f32 angle;
17
18 if (isInitialCall) {
19 script->functionTemp[0] = 0;
20 }
21
22 switch (script->functionTemp[0]) {
23 case 0:
24 script->functionTemp[1] = 0;
25 script->functionTemp[2] = 0;
27 camera->params.basic.skipRecalc = FALSE;
28 ScreenBlurWorkerID = create_worker_frontUI(NULL, N(worker_render_screen_blur));
29 script->functionTemp[0] = 1;
30 case 1:
31 camera->flags |= CAMERA_FLAG_SHAKING;
32 angle = script->functionTemp[1];
33 guRotateF(camera->mtxViewShaking, angle, 0.0f, 0.0f, 1.0f);
34 script->functionTemp[1] = 2.0 * ((1.0 - sin_rad(DEG_TO_RAD(script->functionTemp[2] + 90))) * 360.0);
35 script->functionTemp[2]++;
36 if (script->functionTemp[2] <= 90) {
37 return ApiStatus_BLOCK;
38 }
39 camera->params.basic.skipRecalc = FALSE;
40 camera->flags &= ~CAMERA_FLAG_SHAKING;
41 free_worker(ScreenBlurWorkerID);
42 return ApiStatus_DONE2;
43 }
44
45 return ApiStatus_BLOCK;
46}
47
49
50EvtScript N(EVS_UseItem) = {
51 SetConst(LVarA, ITEM_DIZZY_DIAL)
52 ExecWait(N(UseItemWithEffect))
53 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
54 Call(MoveBattleCamOver, 20)
55 Wait(10)
56 Thread
57 Wait(5)
58 Call(AddBattleCamDist, -250)
59 Call(MoveBattleCamOver, 80)
60 Call(SetBattleCamTargetingModes, BTL_CAM_YADJ_NONE, BTL_CAM_XADJ_NONE, TRUE)
61 Wait(80)
62 Call(AddBattleCamDist, 250)
63 Call(MoveBattleCamOver, 3)
64 Call(SetBattleCamTargetingModes, BTL_CAM_YADJ_NONE, BTL_CAM_XADJ_NONE, TRUE)
66 Call(N(AnimateDizzyDialCameraFX))
67 Thread
68 Call(StartRumble, BTL_RUMBLE_PLAYER_LIGHT)
69 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(1.0))
70 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(4.0))
71 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(3.0))
72 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(2.0))
73 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(1.0))
74 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(0.5))
75 Wait(10)
76 Call(UseBattleCamPreset, BTL_CAM_VIEW_ENEMIES)
77 Call(MoveBattleCamOver, 10)
78 Call(SetBattleCamTargetingModes, BTL_CAM_YADJ_NONE, BTL_CAM_XADJ_NONE, FALSE)
80 Call(InitTargetIterator)
81 Label(0)
82 Call(SetGoalToTarget, ACTOR_SELF)
83 Call(ItemCheckHit, LVar0, DAMAGE_TYPE_NO_CONTACT, 0, LVar0, 0)
85 Goto(1)
86 EndIf
87 Call(GetItemPower, ITEM_DIZZY_DIAL, LVar0, LVar1)
88 Call(MakeStatusField, LVar0, STATUS_FLAG_DIZZY, 100, LVar0)
90 Label(1)
91 Wait(5)
92 Call(ChooseNextTarget, ITER_NEXT, LVar0)
94 Goto(0)
95 EndIf
96 Wait(30)
97 ExecWait(N(PlayerGoHome))
98 Return
99 End
100};
Bytecode EvtScript[]
void N worker_render_screen_blur(void)
Definition dizzy_dial.c:10
#define guRotateF
#define draw_prev_frame_buffer_at_screen_pos
@ BTL_CAM_XADJ_NONE
Definition enums.h:4899
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3575
@ ITER_NO_MORE
Definition enums.h:2030
@ ITER_NEXT
Definition enums.h:2025
@ CAMERA_FLAG_SHAKING
Definition enums.h:4723
@ HIT_RESULT_MISS
Definition enums.h:1956
@ BTL_CAM_DEFAULT
Definition enums.h:4824
@ BTL_CAM_VIEW_ENEMIES
Definition enums.h:4825
@ STATUS_FLAG_DIZZY
Definition enums.h:2818
@ SOUND_DIZZY_DIAL
Definition enums.h:1356
@ BTL_RUMBLE_PLAYER_LIGHT
Definition enums.h:4260
@ ACTOR_SELF
Definition enums.h:2084
@ BTL_CAM_YADJ_NONE
Definition enums.h:4906
@ CAM_BATTLE
Definition enums.h:1801
@ DAMAGE_TYPE_STATUS_ALWAYS_HITS
Definition enums.h:2880
@ DAMAGE_TYPE_NO_CONTACT
Definition enums.h:2878
#define ApiStatus_DONE2
Definition evt.h:118
#define ApiStatus_BLOCK
Definition evt.h:116
void free_worker(s32)
Definition worker.c:176
f32 sin_rad(f32 x)
Definition 43F0.c:713
s32 create_worker_frontUI(void(*updateFunc)(void), void(*drawFunc)(void))
Definition worker.c:63
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
ApiStatus ShakeCam(Evt *script, b32 isInitialCall)
ApiStatus GetItemPower(Evt *script, b32 isInitialCall)
#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 Goto(LABEL_ID)
Moves execution to the given label.
Definition macros.h:232
#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 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 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 DEG_TO_RAD(deg)
Definition macros.h:134
#define LVar1
Definition macros.h:149
#define LVarA
Definition macros.h:158
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#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
union Camera::@17 params
Matrix4f mtxViewShaking
Camera gCameras[4]
Definition cam_main.c:17