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 "sprite/player.h"
3
4extern f32 JumpedOnSwitchX;
5extern f32 JumpedOnSwitchZ;
6
7// private functions
8void initialize_jump(void);
11
12void initialize_jump(void) {
13 PlayerStatus* playerStatus = &gPlayerStatus;
14 CollisionStatus* collisionStatus = &gCollisionStatus;
15 AnimID anim;
16
17 playerStatus->actionSubstate = JUMP_SUBSTATE_0;
18 playerStatus->timeInAir = 0;
19 playerStatus->peakJumpTime = 0;
21 playerStatus->flags |= PS_FLAG_JUMPING;
22 playerStatus->jumpFromPos.x = playerStatus->pos.x;
23 playerStatus->jumpFromPos.z = playerStatus->pos.z;
24 playerStatus->jumpFromHeight = playerStatus->pos.y;
25
27
28 if (playerStatus->animFlags & PA_FLAG_8BIT_MARIO) {
29 anim = ANIM_MarioW3_8bit_Jump;
30 } else if (!(playerStatus->animFlags & (PA_FLAG_USING_WATT | PA_FLAG_WATT_IN_HANDS))) {
31 anim = ANIM_Mario1_Jump;
32 } else {
33 anim = ANIM_MarioW1_JumpWatt;
34 }
36
37 collisionStatus->lastTouchedFloor = collisionStatus->curFloor;
38 collisionStatus->curFloor = NO_COLLIDER;
39}
40
42 PlayerStatus* playerStatus = &gPlayerStatus;
43 AnimID anim;
44
45 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
46 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
48
49 if (playerStatus->actionState == ACTION_STATE_LAUNCH) {
51 } else {
53 }
54
55 if (playerStatus->actionState == ACTION_STATE_JUMP) {
56 if (playerStatus->animFlags & PA_FLAG_8BIT_MARIO) {
58 } else {
60 }
61 }
62 }
63
64 if (playerStatus->animFlags & PA_FLAG_8BIT_MARIO) {
65 anim = ANIM_MarioW3_8bit_Jump;
66 } else if (!(playerStatus->animFlags & (PA_FLAG_USING_WATT | PA_FLAG_WATT_IN_HANDS))) {
67 anim = ANIM_Mario1_Jump;
68 } else {
69 anim = ANIM_MarioW1_JumpWatt;
70 }
72
73 playerStatus->timeInAir++;
74}
75
77 PlayerStatus* playerStatus = &gPlayerStatus;
78 CollisionStatus* collisionStatus = &gCollisionStatus;
79 AnimID anim;
80
81 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
82 Entity* entity = get_entity_by_index(collisionStatus->curFloor);
83
84 JumpedOnSwitchX = entity->pos.x;
85 JumpedOnSwitchZ = entity->pos.z;
89 }
90
91 playerStatus->timeInAir++;
92
93 if (playerStatus->actionSubstate != JUMP_SUBSTATE_1) {
94 return;
95 }
96
97 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
99 playerStatus->flags |= PS_FLAG_FALLING;
100
101 if (!(playerStatus->animFlags & (PA_FLAG_USING_WATT | PA_FLAG_WATT_IN_HANDS))) {
102 anim = ANIM_Mario1_Fall;
103 } else {
104 anim = ANIM_MarioW1_FallWatt;
105 }
106
109 }
110
111 playerStatus->actionSubstate++;
112}
113
115 PlayerStatus* playerStatus = &gPlayerStatus;
116
117 if (playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS) {
119 return;
120 }
121
122 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
123 s32 anim;
124
126 playerStatus->flags |= PS_FLAG_FALLING;
127
128 if (playerStatus->animFlags & PA_FLAG_8BIT_MARIO) {
129 anim = ANIM_MarioW3_8bit_Jump;
130 } else if (!(playerStatus->animFlags & (PA_FLAG_USING_WATT | PA_FLAG_WATT_IN_HANDS))) {
131 anim = ANIM_Mario1_Fall;
132 } else {
133 anim = ANIM_MarioW1_FallWatt;
134 }
137 }
138 playerStatus->timeInAir++;
139}
140
142 PlayerStatus* playerStatus = &gPlayerStatus;
143 s32 colliderID;
144 s32 surfaceType;
145 f32 posX, posY, posZ;
146 f32 hitRx, hitRz;
147 f32 hitDirX, hitDirZ;
148 f32 height;
149
150 if (playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS) {
152 return;
153 }
154
155 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
157 playerStatus->flags |= PS_FLAG_FALLING;
159 }
160
161 playerStatus->timeInAir++;
163 posX = playerStatus->pos.x;
164 posY = playerStatus->pos.y;
165 posZ = playerStatus->pos.z;
166 height = playerStatus->colliderHeight;
167
168 colliderID = player_raycast_below_cam_relative(playerStatus, &posX, &posY, &posZ, &height, &hitRx, &hitRz, &hitDirX, &hitDirZ);
169 surfaceType = get_collider_flags(colliderID) & COLLIDER_FLAGS_SURFACE_TYPE_MASK;
170 if (!(surfaceType == SURFACE_TYPE_SPIKES || surfaceType == SURFACE_TYPE_LAVA) && check_input_jump()) {
172 playerStatus->flags &= ~PS_FLAG_AIRBORNE;
174 }
175}
176
178 PlayerStatus* playerStatus = &gPlayerStatus;
179 AnimID anim;
180
181 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
182 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
183 playerStatus->flags &= ~(PS_FLAG_JUMPING | PS_FLAG_FLYING);
184 playerStatus->flags |= PS_FLAG_FALLING;
185
186 if (!(playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS)) {
187 anim = ANIM_Mario1_Fall;
188 } else {
189 anim = ANIM_Peach1_StepDown;
190 }
191
194 }
195 playerStatus->timeInAir++;
196}
197
199 PlayerStatus* playerStatus = &gPlayerStatus;
200
201 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
202 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
203 playerStatus->flags &= ~(PS_FLAG_JUMPING | PS_FLAG_FLYING);
204 playerStatus->flags |= PS_FLAG_FALLING;
206
207 if (playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS) {
208 suggest_player_anim_allow_backward(ANIM_Peach1_StepDown);
209 }
210 }
211 playerStatus->timeInAir++;
213}
u32 AnimID
@ JUMP_SUBSTATE_1
Definition enums.h:2471
@ JUMP_SUBSTATE_0
Definition enums.h:2470
@ SURFACE_TYPE_LAVA
Definition enums.h:4673
@ SURFACE_TYPE_SPIKES
Definition enums.h:4672
@ PS_FLAG_FALLING
Definition enums.h:3036
@ PS_FLAG_JUMPING
Definition enums.h:3035
@ PS_FLAG_ACTION_STATE_CHANGED
Definition enums.h:3084
@ PS_FLAG_FLYING
Definition enums.h:3037
@ PS_FLAG_ARMS_RAISED
Definition enums.h:3063
@ PS_FLAG_SCRIPTED_FALL
Definition enums.h:3071
@ COLLIDER_FLAGS_SURFACE_TYPE_MASK
Definition enums.h:4693
@ PA_FLAG_WATT_IN_HANDS
Definition enums.h:3092
@ PA_FLAG_8BIT_MARIO
Definition enums.h:3105
@ PA_FLAG_USING_PEACH_PHYSICS
Definition enums.h:3103
@ PA_FLAG_USING_WATT
Definition enums.h:3090
@ SOUND_JUMP_8BIT_MARIO
Definition enums.h:1425
@ SOUND_QUICK_PLAYER_JUMP
Definition enums.h:1424
@ ACTION_STATE_JUMP
Definition enums.h:2430
@ ACTION_STATE_LAUNCH
Shy Guy Toybox jack-in-the-boxes.
Definition enums.h:2433
@ CAMERA_MOVE_IGNORE_PLAYER_Y
Definition enums.h:4732
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737
@ CAM_DEFAULT
Definition enums.h:1800
Entity * get_entity_by_index(s32 index)
Definition entity.c:530
HitID player_raycast_below_cam_relative(PlayerStatus *playerStatus, f32 *outX, f32 *outY, f32 *outZ, f32 *outLength, f32 *hitRx, f32 *hitRz, f32 *hitDirX, f32 *hitDirZ)
Definition 77480.c:193
s32 disable_player_input(void)
Definition 77480.c:990
s32 get_collider_flags(s32 colliderID)
Definition collision.c:481
s32 phys_adjust_cam_on_landing(void)
Definition 7E9D0.c:46
void set_action_state(s32 actionState)
Definition 7E9D0.c:209
void phys_update_interact_collider(void)
Definition 7BB60.c:1127
void suggest_player_anim_allow_backward(AnimID anim)
Definition 77480.c:894
b32 check_input_jump(void)
Definition 7E9D0.c:344
void phys_init_integrator_for_current_state(void)
Definition 7BB60.c:272
void sfx_play_sound_at_player(s32 soundID, s32 arg1)
Definition sfx.c:521
#define NO_COLLIDER
Definition macros.h:156
CollisionStatus gCollisionStatus
Definition 7BB60.c:6
Camera gCameras[4]
Definition cam_main.c:17
PlayerStatus gPlayerStatus
Definition 77480.c:39
void action_update_peach_step_down(void)
Definition jump.c:198
void action_update_step_down(void)
Definition jump.c:141
f32 JumpedOnSwitchZ
Definition 7BB60.c:8
void action_update_jump(void)
Definition jump.c:41
void action_update_peach_falling(void)
Definition jump.c:177
void initialize_jump(void)
Definition jump.c:12
void action_update_landing_on_switch(void)
Definition jump.c:76
f32 JumpedOnSwitchX
Definition 7BB60.c:7
void action_update_falling(void)
Definition jump.c:114