Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
victory.c
Go to the documentation of this file.
1#include "states.h"
2#include "script_api/battle.h"
3
4enum {
14};
15
18 Actor* player = battleStatus->playerActor;
19 Actor* partner = battleStatus->partnerActor;
20 Evt* script;
21
22 switch (gBattleSubState) {
25 if (partner != NULL) {
27 }
28
29 battleStatus->stateFreezeCount = 0;
30 if (battleStatus->outtaSightActive == 0) {
32 } else {
33 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
34 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
35 partner->handlePhaseScript = script;
36 partner->handlePhaseScriptID = script->id;
37 script->owner1.actorID = ACTOR_PARTNER;
39 }
40
41 break;
43 if (!does_script_exist(partner->handlePhaseScriptID)) {
44 battleStatus->outtaSightActive = 0;
46 }
47 break;
48 }
49
50 switch (gBattleSubState) {
53 if (partner != NULL) {
55 }
61
63 if (player->koStatus == STATUS_KEY_KO) {
66 }
67 player->debuff = 0;
68 player->staticStatus = 0;
69 player->stoneStatus = 0;
70 player->transparentStatus = 0;
71 player->koStatus = 0;
72 player->koDuration = 0;
74
75 if (partner != NULL) {
76 if (partner->koStatus == STATUS_KEY_KO) {
79 }
80 partner->debuff = 0;
81 partner->staticStatus = 0;
82 partner->stoneStatus = 0;
83 partner->transparentStatus = 0;
84 partner->koStatus = 0;
85 partner->koDuration = 0;
86 partner->disableEffect->data.disableX->koDuration = 0;
87 }
88 break;
91 break;
92 }
93 player->handleEventScript = NULL;
94
95 if (partner != NULL) {
96 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
97 break;
98 }
99 partner->handleEventScript = NULL;
100 }
102 break;
103 }
104
108 } else {
109 partner->state.curPos.x = partner->curPos.x;
110 partner->state.curPos.z = partner->curPos.z;
111 partner->state.goalPos.x = player->curPos.x;
112 partner->state.goalPos.z = player->curPos.z;
113 partner->state.moveTime = 4;
114 partner->state.angle = 0.0f;
116 }
117 }
118
120 if (partner->state.moveTime != 0) {
121 partner->curPos.x += (partner->state.goalPos.x - partner->curPos.x) / partner->state.moveTime;
122 partner->curPos.z += (partner->state.goalPos.z - partner->curPos.z) / partner->state.moveTime;
123 player->curPos.x += (partner->state.curPos.x - player->curPos.x) / partner->state.moveTime;
124 player->curPos.z += (partner->state.curPos.z - player->curPos.z) / partner->state.moveTime;
125 }
126 partner->curPos.z += sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
127 partner->yaw = clamp_angle(-partner->state.angle);
128 player->curPos.z -= sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
129 player->yaw = clamp_angle(-partner->state.angle);
130 partner->state.angle += 90.0f;
131
132 if (partner->state.moveTime != 0) {
133 partner->state.moveTime--;
134 } else {
135 partner->curPos.x = partner->state.goalPos.x;
136 partner->curPos.z = partner->state.goalPos.z;
137 player->curPos.x = partner->state.curPos.x;
138 player->curPos.z = partner->state.curPos.z;
139 partner->homePos.x = partner->curPos.x;
140 partner->homePos.z = partner->curPos.z;
141 player->homePos.x = player->curPos.x;
142 player->homePos.z = player->curPos.z;
145 }
146 }
147
150 if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_EXP_BOOST) {
151 if (battleStatus->totalStarPoints == 0) {
152 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
155 } else {
158 player->takeTurnScript = script;
159 player->takeTurnScriptID = script->id;
160 script->owner1.actorID = ACTOR_PLAYER;
161 }
162 }
166 }
167
169 if (BattleSubstateDelay != 0) {
171 } else {
172 if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnScriptID)) {
173 player->takeTurnScript = NULL;
174 if (battleStatus->nextMerleeSpellType != MERLEE_SPELL_EXP_BOOST) {
176 } else {
177 battleStatus->incrementStarPointDelay = 20;
178 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
180 battleStatus->pendingStarPoints = battleStatus->totalStarPoints
181 + battleStatus->pendingStarPoints + battleStatus->pendingStarPoints;
182 }
183 }
184 }
185 }
186
188 if (battleStatus->pendingStarPoints <= 0) {
191 }
192 if (gPlayerData.battlesWon < 9999) {
194 }
197 } else {
199 }
202 bgm_set_song(0, -1, 0, 1500, 8);
203 }
205 } else {
207 }
208 }
209 }
210}
211
213}
BSS s32 PopupMenu_SelectedIndex
s32 bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume)
BSS s32 BattleSubstateDelay
struct EffectInstance * disableEffect
struct Evt * takeTurnScript
s8 transparentStatus
struct Evt * handleEventScript
s32 takeTurnScriptID
Vec3f homePos
s32 handleEventScriptID
Vec3f curPos
#define clamp_angle
struct DisableXFXData * disableX
Definition effects.h:2529
EffectInstanceDataPtr data
Definition effects.h:2605
@ MERLEE_SPELL_EXP_BOOST
Definition enums.h:1939
@ MERLEE_SPELL_NONE
Definition enums.h:1936
@ BS_FLAGS1_PLAYER_IN_BACK
Definition enums.h:3622
@ BS_FLAGS1_DISABLE_CELEBRATION
Definition enums.h:3619
@ BS_FLAGS1_BATTLE_FLED
Definition enums.h:3620
@ BS_FLAGS1_STAR_POINTS_DROPPED
Definition enums.h:3626
@ PHASE_MERLEE_EXP_BONUS
Definition enums.h:2105
@ PHASE_ENEMY_BEGIN
Definition enums.h:2101
@ BS_FLAGS2_DONT_STOP_MUSIC
Definition enums.h:3652
@ STATUS_KEY_KO
Definition enums.h:2814
@ BTL_CAM_DEFAULT
Definition enums.h:4409
@ BATTLE_STATE_CELEBRATION
Definition enums.h:3695
@ BATTLE_STATE_END_BATTLE
Definition enums.h:3694
@ ACTOR_PLAYER
Definition enums.h:2118
@ ACTOR_PARTNER
Definition enums.h:2119
@ ACTOR_FLAG_SHOW_STATUS_ICONS
Definition enums.h:3377
@ ACTOR_FLAG_USING_IDLE_ANIM
Definition enums.h:3376
@ OUTCOME_ENEMY_FLED
Definition enums.h:1931
@ OUTCOME_PLAYER_WON
Definition enums.h:1928
@ EVENT_RECOVER_FROM_KO
Definition enums.h:2203
@ EVT_PRIORITY_A
Definition evt.h:154
void dispatch_event_player(s32)
Definition dmg_player.c:131
void btl_cam_use_preset(s32)
Definition camera.c:1919
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
s32 does_script_exist(s32 id)
f32 sin_rad(f32 x)
Definition 43F0.c:711
void btl_set_state(s32 battleState)
void dispatch_event_partner(s32)
Definition dmg_partner.c:7
EvtScript EVS_Mario_HandlePhase
EncounterStatus gCurrentEncounter
Definition encounter.c:175
s8 battleOutcome
Definition npc.h:372
#define DEG_TO_RAD(deg)
Definition macros.h:146
PlayerData gPlayerData
Definition 77480.c:39
BattleStatus gBattleStatus
Definition battle.cpp:14
s32 gBattleSubState
Definition battle.cpp:17
@ BTL_SUBSTATE_AWAIT_SWAP
Definition victory.c:13
@ BTL_SUBSTATE_AWAIT_OUTTA_SIGHT
Definition victory.c:6
@ BTL_SUBSTATE_CHECK_MERLEE
Definition victory.c:7
@ BTL_SUBSTATE_CHECK_OUTTA_SIGHT
Definition victory.c:5
@ BTL_SUBSTATE_AWAIT_MERLEE
Definition victory.c:8
@ BTL_SUBSTATE_AWAIT_RECOVER_KO
Definition victory.c:11
@ BTL_SUBSTATE_RECOVER_STATUS
Definition victory.c:10
@ BTL_SUBSTATE_DONE
Definition victory.c:9
@ BTL_SUBSTATE_CHECK_SWAP
Definition victory.c:12
void btl_state_draw_victory(void)
Definition victory.c:212
void btl_state_update_victory(void)
Definition victory.c:16