Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
focus.c
Go to the documentation of this file.
1#include "common.h"
2#include "script_api/battle.h"
3#include "sprite/player.h"
4
5#define NAMESPACE battle_move_focus
6
8
9enum {
13};
14
15API_CALLABLE(N(RestoreStarPowerFromPlayer)) {
16 PlayerData* playerData = &gPlayerData;
17 s32 deepFocusSP;
18 s32 superFocusSP;
19
20 script->varTable[0] = RESTORE_NOT_FULL;
21
22 if (playerData->starPower >= playerData->maxStarPower * SP_PER_BAR) {
23 script->varTable[0] = RESTORE_ALREADY_FULL;
24 return ApiStatus_DONE2;
25 }
26
29
30 add_star_power(deepFocusSP + superFocusSP + SP_PER_SEG * 4);
31
32 if (playerData->starPower == playerData->maxStarPower * SP_PER_BAR) {
33 script->varTable[0] = RESTORE_NOW_FULL;
34 }
35
36 return ApiStatus_DONE2;
37}
38
39API_CALLABLE(N(RestoreStarPowerFromPartner)) {
40 PlayerData* playerData = &gPlayerData;
41
42 script->varTable[0] = RESTORE_NOT_FULL;
43
44 if (playerData->starPower >= playerData->maxStarPower * SP_PER_BAR) {
45 script->varTable[0] = RESTORE_ALREADY_FULL;
46 return ApiStatus_DONE2;
47 }
48
50
51 if (playerData->starPower == playerData->maxStarPower * SP_PER_BAR) {
52 script->varTable[0] = RESTORE_NOW_FULL;
53 }
54
55 return ApiStatus_DONE2;
56}
57
58EvtScript N(EVS_UsePower) = {
59 ExecWait(N(EVS_StarPower_WishForSpirit))
60 Call(EnableBattleStatusBar, TRUE)
61 Call(GetOwnerID, LVarA)
64 Call(N(RestoreStarPowerFromPlayer))
65 Wait(30)
67 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
70 Call(ShowMessageBox, BTL_MSG_STAR_POWER_RECHARGED, 60)
72 Call(ShowMessageBox, BTL_MSG_STAR_POWER_MAXED, 60)
74 Call(ShowMessageBox, BTL_MSG_STAR_POWER_FILLED, 60)
76 Call(WaitForMessageBoxDone)
77 Call(PlayerYieldTurn)
78 Call(SetGoalToHome, ACTOR_PLAYER)
79 Call(SetActorSpeed, ACTOR_PLAYER, Float(8.0))
80 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Run)
81 Call(PlayerRunToGoal, 0)
82 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Idle)
83 Else
85 Call(N(RestoreStarPowerFromPartner))
86 Wait(30)
88 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
91 Call(ShowMessageBox, BTL_MSG_STAR_POWER_RECHARGED, 60)
93 Call(ShowMessageBox, BTL_MSG_STAR_POWER_MAXED, 60)
95 Call(ShowMessageBox, BTL_MSG_STAR_POWER_FILLED, 60)
97 Call(WaitForMessageBoxDone)
98 Call(PartnerYieldTurn)
99 Call(SetGoalToHome, ACTOR_PARTNER)
100 Call(SetActorSpeed, ACTOR_PARTNER, Float(8.0))
101 Call(N(SetPartnerWishAnim), PARTNER_WISH_ANIM_RETURN)
102 Call(RunToGoal, ACTOR_PARTNER, 0)
103 Call(N(SetPartnerWishAnim), PARTNER_WISH_ANIM_IDLE)
104 EndIf
105 Return
106 End
107};
Bytecode EvtScript[]
@ BTL_MSG_STAR_POWER_MAXED
Definition enums.h:4085
@ BTL_MSG_STAR_POWER_RECHARGED
Definition enums.h:4084
@ BTL_MSG_STAR_POWER_FILLED
Definition enums.h:4086
@ PARTNER_WISH_ANIM_IDLE
Definition enums.h:3398
@ PARTNER_WISH_ANIM_RETURN
Definition enums.h:3397
@ BTL_CAM_DEFAULT
Definition enums.h:4824
@ ABILITY_DEEP_FOCUS
Definition enums.h:484
@ ABILITY_SUPER_FOCUS
Definition enums.h:485
@ SOUND_STAR_POWER_RECOVERY
Definition enums.h:1384
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_PARTNER
Definition enums.h:2086
#define ApiStatus_DONE2
Definition evt.h:118
@ RESTORE_ALREADY_FULL
Definition focus.c:11
@ RESTORE_NOT_FULL
Definition focus.c:10
@ RESTORE_NOW_FULL
Definition focus.c:12
s32 is_ability_active(s32 arg0)
Definition inventory.c:1725
void add_star_power(s32 amt)
Definition inventory.c:2134
ApiStatus PlaySound(Evt *script, b32 isInitialCall)
ApiStatus FadeBackgroundLighten(Evt *script, b32 isInitialCall)
#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 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 Float(DOUBLE)
Definition macros.h:51
#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 SP_PER_SEG
Definition macros.h:103
#define LVarA
Definition macros.h:158
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#define SP_PER_BAR
Definition macros.h:102
#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 LVar0
Definition macros.h:148
#define Return
Kills the current EVT thread.
Definition macros.h:217
PlayerData gPlayerData
Definition 77480.c:40