Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
jump.c
Go to the documentation of this file.
1#include "common.h"
2#include "battle/action_cmd.h"
3
4#define NAMESPACE action_command_jump
5
6extern s32 actionCmdTableJump[];
7
8enum {
14};
15
16API_CALLABLE(N(init)) {
17 s32 hudElement;
18 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
19
23
26 return ApiStatus_DONE2;
27 }
28
30 actionCommandStatus->actionCommandID = ACTION_COMMAND_JUMP;
31 actionCommandStatus->hudPosX = -48;
32 actionCommandStatus->state = 0;
33 actionCommandStatus->wrongButtonPressed = FALSE;
34 actionCommandStatus->hudPosY = 80;
35
36 hudElement = hud_element_create(&HES_AButton);
37 actionCommandStatus->hudElements[0] = hudElement;
39 hud_element_set_render_pos(hudElement, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
40 hud_element_set_render_depth(hudElement, 0);
41 hud_element_set_alpha(hudElement, 255);
42
43 hudElement = hud_element_create(&HES_RightOn);
44 actionCommandStatus->hudElements[1] = hudElement;
46 hud_element_set_render_pos(hudElement, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
47 hud_element_set_render_depth(hudElement, 0);
48 hud_element_set_alpha(hudElement, 255);
49
50 return ApiStatus_DONE2;
51}
52
53API_CALLABLE(N(start)) {
54 s32 hudElement;
55
56 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
57 BattleStatus* battleStatus = &gBattleStatus;
58 Bytecode* args = script->ptrReadPos;
59
61 battleStatus->actionSuccess = 0;
62 return ApiStatus_DONE2;
63 } else {
65 actionCommandStatus->prepareTime = evt_get_variable(script, *args++);
66 actionCommandStatus->difficulty = evt_get_variable(script, *args++);
67 actionCommandStatus->difficulty = adjust_action_command_difficulty(actionCommandStatus->difficulty);
68 actionCommandStatus->wrongButtonPressed = FALSE;
69 battleStatus->actionSuccess = 0;
70
71 hudElement = actionCommandStatus->hudElements[0];
72 actionCommandStatus->hudPosX = 50;
73 battleStatus->flags1 &= ~BS_FLAGS1_FREE_ACTION_COMMAND;
74 battleStatus->flags1 &= ~BS_FLAGS1_2000;
75 hud_element_set_render_pos(hudElement, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
76 if (actionCommandStatus->showHud) {
78 }
79
80 actionCommandStatus->state = AC_JUMP_STATE_10;
83 return ApiStatus_DONE2;
84 }
85}
86
87void N(update)(void) {
88 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
89 BattleStatus* battleStatus = &gBattleStatus;
90 s32 hudElement;
91 s32 successWindow;
92
93 switch (actionCommandStatus->state) {
94 case AC_JUMP_STATE_0:
97 }
98 actionCommandStatus->state = AC_JUMP_STATE_1;
99 break;
100 case AC_JUMP_STATE_1:
101 if (battleStatus->actionCommandMode == ACTION_COMMAND_MODE_TUTORIAL) {
103 }
104
105 actionCommandStatus->hudPosX += 20;
106 if (actionCommandStatus->hudPosX > 50) {
107 actionCommandStatus->hudPosX = 50;
108 }
109
110 hudElement = actionCommandStatus->hudElements[0];
111 hud_element_set_render_pos(hudElement, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
112 if (actionCommandStatus->showHud) {
114 }
115
116 if (actionCommandStatus->autoSucceed) {
117 hudElement = actionCommandStatus->hudElements[1];
118 hud_element_set_render_pos(hudElement, actionCommandStatus->hudPosX + 50, actionCommandStatus->hudPosY);
119 if (actionCommandStatus->showHud) {
121 break;
122 }
123 }
124 break;
125 case AC_JUMP_STATE_10:
126 if (battleStatus->actionCommandMode == ACTION_COMMAND_MODE_TUTORIAL) {
128 }
129
130 successWindow = battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty];
131 if (((actionCommandStatus->prepareTime - successWindow) - 2) <= 0) {
132 hud_element_set_script(actionCommandStatus->hudElements[0], &HES_AButtonDown);
133 }
134 if ((battleStatus->curButtonsPressed & BUTTON_A) && !actionCommandStatus->autoSucceed) {
135 actionCommandStatus->wrongButtonPressed = TRUE;
136 battleStatus->actionResult = ACTION_RESULT_EARLY;
137 }
138 if ((actionCommandStatus->prepareTime - successWindow) > 0) {
139 actionCommandStatus->prepareTime -= 1;
140 break;
141 }
142
143 actionCommandStatus->frameCounter = battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty];
144 battleStatus->actionSuccess = -1;
145 actionCommandStatus->state = AC_JUMP_STATE_11;
146 // fall through
147 case AC_JUMP_STATE_11:
148 if (battleStatus->actionCommandMode == ACTION_COMMAND_MODE_TUTORIAL) {
150 }
151 if (battleStatus->actionCommandMode >= ACTION_COMMAND_MODE_TUTORIAL) {
152 if (actionCommandStatus->frameCounter == 0) {
153 break;
154 }
155 } else {
156 if (battleStatus->actionSuccess >= 0) {
157 hudElement = actionCommandStatus->hudElements[0];
158 if (actionCommandStatus->showHud) {
160 }
161 }
162 }
163
164 if (battleStatus->actionSuccess < 0) {
165 if (((battleStatus->curButtonsPressed & BUTTON_A) &&
166 !actionCommandStatus->wrongButtonPressed) ||
167 actionCommandStatus->autoSucceed) {
168 battleStatus->actionSuccess = 1;
169 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
171 }
172 }
173
174 if (actionCommandStatus->frameCounter == 0) {
175 if (battleStatus->actionSuccess == 1) {
177 }
178 if (battleStatus->actionCommandMode == ACTION_COMMAND_MODE_TUTORIAL) {
180 }
181 actionCommandStatus->frameCounter = 5;
182 actionCommandStatus->state = AC_JUMP_STATE_CLEANUP;
183 break;
184 }
185 actionCommandStatus->frameCounter--;
186 break;
188 if (actionCommandStatus->frameCounter != 0) {
189 actionCommandStatus->frameCounter--;
190 break;
191 }
193 break;
194 }
195}
196
203
BSS ActionCommandStatus gActionCommandStatus
Definition action_cmd.c:91
void func_80269160(void)
Definition action_cmd.c:655
void action_command_free(void)
Definition action_cmd.c:446
s32 adjust_action_command_difficulty(s32 arg0)
Definition action_cmd.c:101
void action_command_init_status(void)
Definition action_cmd.c:256
void func_80269118(void)
Definition action_cmd.c:641
HudScript HES_AButton
HudScript HES_RightOn
HudScript HES_AButtonDown
@ ACTION_COMMAND_MODE_TUTORIAL
Definition action_cmd.h:40
@ ACTION_COMMAND_MODE_NOT_LEARNED
Definition action_cmd.h:38
@ AC_JUMP_STATE_CLEANUP
Definition jump.c:13
@ AC_JUMP_STATE_1
Definition jump.c:10
@ AC_JUMP_STATE_0
Definition jump.c:9
@ AC_JUMP_STATE_11
Definition jump.c:12
@ AC_JUMP_STATE_10
Definition jump.c:11
s32 actionCmdTableJump[]
Definition action_cmd.c:28
void N free(void)
Definition jump.c:204
void N update(void)
Definition jump.c:87
void N draw(void)
Definition jump.c:197
@ ACTION_COMMAND_JUMP
Definition enums.h:3473
@ BUTTON_A
Definition enums.h:2790
@ BS_FLAGS1_2000
Definition enums.h:3582
@ DEMO_BTL_FLAG_ENABLED
Definition enums.h:3543
@ ACTION_RESULT_EARLY
Definition enums.h:1966
@ ACTION_RESULT_SUCCESS
Definition enums.h:1968
@ ACTION_RESULT_FAIL
Definition enums.h:1967
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
void btl_set_popup_duration(s32 duration)
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
void hud_element_set_alpha(s32 id, s32 opacity)
void hud_element_set_script(s32 id, HudScript *anim)
void hud_element_set_render_depth(s32 id, s32 z)
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
s32 hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
void hud_element_set_flags(s32 id, s32 flags)
Turns on the given flags.
void hud_element_clear_flags(s32 id, s32 flags)
Turns off the given flags.
void hud_element_draw_clipped(s32 id)
void hud_element_free(s32 id)
@ HUD_ELEMENT_FLAG_DISABLED
Definition hud_element.h:74
@ HUD_ELEMENT_FLAG_80
Definition hud_element.h:80
s32 * actionCmdDifficultyTable
GameStatus * gGameStatusPtr
Definition main_loop.c:32
BattleStatus gBattleStatus
Definition battle.c:11
void N init(Npc *bombette)
Definition bombette.c:66