Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
action_cmd.h
Go to the documentation of this file.
1#ifndef _BATTLE_ACTION_CMD_H_
2#define _BATTLE_ACTION_CMD_H_
3
4#include "common.h"
5#include "hud_element.h"
6#include "battle.h"
30
31// standard states for action commands
32// used by every command except three_chances and tidal_wave
33enum {
34 AC_STATE_INIT = 0, // create hud elements
35 AC_STATE_APPEAR = 1, // hud elements move into position
36 AC_STATE_START = 10, // begin listening for input
37 AC_STATE_ACTIVE = 11, // responding to player input
38 AC_STATE_DISPOSE = 12, // delay and disappear
39};
40
42 AC_DIFFICULTY_0 = 0, // easiest
43 AC_DIFFICULTY_1 = 1, // very easy
44 AC_DIFFICULTY_2 = 2, // easy
45 AC_DIFFICULTY_3 = 3, // standard
46 AC_DIFFICULTY_4 = 4, // harder
47 AC_DIFFICULTY_5 = 5, // hard
48 AC_DIFFICULTY_6 = 6, // very hard
49 AC_DIFFICULTY_7 = 7, // hardest
50};
51
57
65
66#define AC_QUALITY_FAILED -1
67
68// mash meter has 100 units for each 1%
69#define ONE_PCT_MASH 100
70
71// mash meter goes up to 100%
72#define MAX_MASH_PCT 100
73
74// total number of units in the mash meter
75#define MAX_MASH_UNITS (MAX_MASH_PCT * ONE_PCT_MASH)
76
77#define SCALE_BY_PCT(x, pct) ((x) * (pct) / 100)
78#define PCT_TO_TABLE_IDX(table, pct) ((pct) / (ONE_PCT_MASH / ARRAY_COUNT(table)))
79#define PCT_TO_TABLE_RATE(table, pct) (table[PCT_TO_TABLE_IDX(table, pct)])
80
81typedef struct ActionCommandStatus {
82 /* 0x00 */ s32 workerID;
83 /* 0x04 */ HudElemID hudElemIDs[16];
84 /* 0x44 */ s16 meterFillLevel; // 0 to MAX_MASH_UNITS
85 /* 0x46 */ s16 escapeThreshold;
86 /* 0x48 */ s16 meterFillWidth; // X100
87 /* 0x4A */ s16 actionCommandID;
88 /* 0x4C */ s16 state;
89 /* 0x4E */ s16 prepareTime;
90 /* 0x50 */ s16 difficulty; // see enum: ActionCommandDifficulty
91 /* 0x52 */ s16 duration;
92 /* 0x54 */ s16 stateTimer;
93 /* 0x56 */ s16 hudPosX;
94 /* 0x58 */ s16 hudPosY;
95 /* 0x5A */ s16 escapeChance; // used by air_lift (via AirLiftChance), break_free (30), and flee (random 0-1).
96 /* 0x5C */ union {
97 struct {
98 s8 unk_5C;
99 s8 unk_5D;
100 } any;
101 struct {
102 b8 holdingLeft;
103 } airRaid;
104 struct {
105 s8 dir;
106 } breakFree;
107 struct {
108 b8 holdingLeft;
109 } fireShell;
110 struct {
111 s8 dir;
112 s8 drainDelay; // only found in unused variant
113 } flee;
114 struct {
115 b8 holdingLeft;
116 } smack;
117 struct {
118 s8 tossState;
119 } spinySurge;
120 struct {
121 b8 holdingLeft;
122 } spook;
123 struct {
124 b8 draining;
125 } squirt;
126 struct {
127 b8 hadCorrectTiming;
128 s8 time;
129 } threeChances;
130 struct {
131 s8 prevButton;
132 s8 inputCount;
133 } tidalWave;
134 };
135 /* 0x5E */ s8 autoSucceed;
138 /* 0x61 */ b8 showHud;
140 /* 0x63 */ char pad_63[1];
141 /* 0x64 */ union {
142 s16 variation; // used to select different variants of an action command
143 s16 statusChance; // chance of applying special status; higher values make mashing easier
144 };
145 /* 0x66 */ s16 thresholdMoveDir;
146 /* 0x68 */ b16 isMeterFilled;
148 /* 0x6C */ s16 hudPrepareTime;
149 /* 0x6E */ b16 hitsTakenIsMax;
150 /* 0x70 */ s16 lookBackCounter;
152 /* 0x74 */ s16 mashMeterCutoffs[6]; // upper bounds for each interval
155
157
158extern HudScript HES_100pct;
190
192void action_command_free(void);
196
197void draw_mash_meter_multicolor_with_divisor(s32 posX, s32 posY, s32 fillValue, s32 divisor);
198void draw_mash_meter_blink(s32 posX, s32 posY, s32 fillValue);
199void draw_mash_meter_multicolor(s32 posX, s32 posY, s32 fillValue);
200void draw_mash_meter_mode_with_divisor(s32 posX, s32 posY, s32 fillValue, s32 divisor, s32 colorMode);
201void draw_mash_meter_blink_with_divisor(s32 posX, s32 posY, s32 fillValue, s32 divisor);
203s32 check_block_input(s32 buttonMask);
204
205API_CALLABLE(LoadActionCommand);
206API_CALLABLE(SetActionDifficultyTable);
207API_CALLABLE(SetupMashMeter);
208API_CALLABLE(GetSmashActionQuality);
209API_CALLABLE(SetActionSuccess);
210API_CALLABLE(SetActionCommandMode);
211API_CALLABLE(GetActionCommandMode);
212API_CALLABLE(SetActionHudPrepareTime);
213API_CALLABLE(GetCommandAutoSuccess);
214API_CALLABLE(SetCommandAutoSuccess);
215API_CALLABLE(func_802693F0);
216API_CALLABLE(InterruptActionCommand);
217API_CALLABLE(InterruptLeechActionCommand);
218API_CALLABLE(ShowActionHud);
219API_CALLABLE(GetMashActionQuality);
220API_CALLABLE(GetJumpActionQuality);
221API_CALLABLE(SetActionResult);
222API_CALLABLE(GetBlockResult);
223API_CALLABLE(GetActionProgress);
224API_CALLABLE(SetActionProgress);
225API_CALLABLE(GetActionResultTier);
226API_CALLABLE(SetActionResultTier);
227
228#endif
HudScript HES_TimingCharge3
void create_action_command_ui_worker(void)
Definition action_cmd.c:531
HudScript HES_MashBButton1
HudScript HES_BButton
HudScript HES_AButton
void draw_mash_meter_blink_with_divisor(s32 posX, s32 posY, s32 fillValue, s32 divisor)
Definition action_cmd.c:251
HudElemID hudElemIDs[16]
Definition action_cmd.h:83
HudScript HES_TimingReady
HudScript HES_TimingOK
@ AC_STATE_APPEAR
Definition action_cmd.h:35
@ AC_STATE_DISPOSE
Definition action_cmd.h:38
@ AC_STATE_INIT
Definition action_cmd.h:34
@ AC_STATE_ACTIVE
Definition action_cmd.h:37
@ AC_STATE_START
Definition action_cmd.h:36
ActionCommandDifficulty
Definition action_cmd.h:41
@ AC_DIFFICULTY_2
Definition action_cmd.h:44
@ AC_DIFFICULTY_7
Definition action_cmd.h:49
@ AC_DIFFICULTY_0
Definition action_cmd.h:42
@ AC_DIFFICULTY_1
Definition action_cmd.h:43
@ AC_DIFFICULTY_3
Definition action_cmd.h:45
@ AC_DIFFICULTY_4
Definition action_cmd.h:46
@ AC_DIFFICULTY_6
Definition action_cmd.h:48
@ AC_DIFFICULTY_5
Definition action_cmd.h:47
void draw_mash_meter_multicolor(s32 posX, s32 posY, s32 fillValue)
Definition action_cmd.c:226
HudScript HES_StickTapNeutral
HudScript HES_CDownButtonHeld
HudScript HES_TimingCharge4b
void action_command_free(void)
Definition action_cmd.c:446
MashMeterColorModes
Definition action_cmd.h:52
@ MASH_METER_MODE_ONE_COLOR
Definition action_cmd.h:55
@ MASH_METER_MODE_MULTI_COLOR
Definition action_cmd.h:54
@ MASH_METER_MODE_BLINK
Definition action_cmd.h:53
HudScript HES_StickNeutral
ActionCommandStatus gActionCommandStatus
Definition action_cmd.c:91
HudScript HES_TimingBar3Chances
void increment_action_command_attempt_count(void)
Definition action_cmd.c:641
HudScript HES_TimingWait
HudScript HES_TimingCharge4a
HudScript HES_TimingCharge4c
HudScript HES_BlueMeter
HudScript HES_BButtonHeld
void draw_mash_meter_multicolor_with_divisor(s32 posX, s32 posY, s32 fillValue, s32 divisor)
Definition action_cmd.c:231
s32 adjust_action_command_difficulty(s32 arg0)
Definition action_cmd.c:101
void draw_mash_meter_mode_with_divisor(s32 posX, s32 posY, s32 fillValue, s32 divisor, s32 colorMode)
Definition action_cmd.c:241
HudScript HES_RunAwayOK
HudScript HES_MashAButton
HudScript HES_PressAButton
HudScript HES_RightOn
HudScript HES_StickMashLeft
HudScript HES_StickHoldLeft
HudScript HES_AButtonDown
void draw_mash_meter_blink(s32 posX, s32 posY, s32 fillValue)
Definition action_cmd.c:246
void increment_action_command_success_count(void)
Definition action_cmd.c:655
HudScript HES_100pct
HudScript HES_FillGaugeResult
HudScript HES_TimingMiss
void action_command_init_status(void)
Definition action_cmd.c:256
HudScript HES_TimingCharge2
HudScript HES_TimingCharge1
HudScript HES_PressBButton
ActionCommandModes
Definition action_cmd.h:58
@ AC_MODE_TUTORIAL_WAIT_INPUT
Definition action_cmd.h:63
@ AC_MODE_TUTORIAL_BLOCK
Definition action_cmd.h:59
@ AC_MODE_TUTORIAL
Definition action_cmd.h:62
@ AC_MODE_NOT_LEARNED
Definition action_cmd.h:60
@ AC_MODE_LEARNED
Definition action_cmd.h:61
HudScript HES_RunningAway
s32 check_block_input(s32 buttonMask)
Definition action_cmd.c:537
HudScript HES_PressCDownButton
HudScript HES_TimingBar1Chance
s32 HudElemID
s16 b16
s8 b8
s32 HudScript[]
Definition hud_element.h:9