Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
slide.c File Reference

Go to the source code of this file.

Enumerations

enum  {
  SUBSTATE_SLIDING = 0 , SUBSTATE_STOP = 1 , SUBSTATE_LAUNCH = 2 , SUBSTATE_FALL = 3 ,
  SUBSTATE_CRASH = 4 , SUBSTATE_GET_UP = 5 , SUBSTATE_DUST_OFF = 6 , SUBSTATE_DONE = 7
}
 

Functions

void func_802B6000_E27510 (void)
 
void action_update_sliding (void)
 

Variables

BSS f32 SlideAcceleration
 
BSS f32 MaxSlideAccel
 
BSS f32 MaxSlideVelocity
 
BSS f32 SlideLaunchSpeed
 
BSS f32 D_802B6790
 
BSS f32 D_802B6794
 
BSS f32 D_802B6798
 
BSS s32 D_802B679C
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SUBSTATE_SLIDING 
SUBSTATE_STOP 
SUBSTATE_LAUNCH 
SUBSTATE_FALL 
SUBSTATE_CRASH 
SUBSTATE_GET_UP 
SUBSTATE_DUST_OFF 
SUBSTATE_DONE 

Definition at line 13 of file slide.c.

13 {
15 SUBSTATE_STOP = 1,
17 SUBSTATE_FALL = 3,
21 SUBSTATE_DONE = 7,
22};
@ SUBSTATE_FALL
Definition slide.c:17
@ SUBSTATE_STOP
Definition slide.c:15
@ SUBSTATE_CRASH
Definition slide.c:18
@ SUBSTATE_LAUNCH
Definition slide.c:16
@ SUBSTATE_SLIDING
Definition slide.c:14
@ SUBSTATE_DONE
Definition slide.c:21
@ SUBSTATE_GET_UP
Definition slide.c:19
@ SUBSTATE_DUST_OFF
Definition slide.c:20

Function Documentation

◆ func_802B6000_E27510()

void func_802B6000_E27510 ( void )

Definition at line 24 of file slide.c.

24 {
25 PlayerStatus* playerStatus = &gPlayerStatus;
26 SlideParams* slide = playerStatus->slideParams;
27
28 playerStatus->gravityIntegrator[0] = slide->integrator[0];
29 playerStatus->gravityIntegrator[1] = slide->integrator[1];
30 playerStatus->gravityIntegrator[2] = slide->integrator[2];
31 playerStatus->gravityIntegrator[3] = slide->integrator[3];
32 playerStatus->heading = slide->heading;
36}
SlideParams * slideParams
f32 gravityIntegrator[4]
BSS f32 SlideLaunchSpeed
Definition slide.c:7
BSS f32 MaxSlideAccel
Definition slide.c:5
BSS f32 MaxSlideVelocity
Definition slide.c:6
PlayerStatus gPlayerStatus
Definition 77480.c:39

Referenced by action_update_sliding().

◆ action_update_sliding()

void action_update_sliding ( void )

Definition at line 38 of file slide.c.

38 {
39 PlayerStatus* playerStatus = &gPlayerStatus;
40 CollisionStatus* collisionStatus;
41 s32 surfaceType;
42 f32 sinA, cosA;
43 f32 speed;
44 f32 posX, posY, posZ, depth;
45 f32 hitRx, hitRy, hitDirX, hitDirZ;
46 s32 hitID;
47
48 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
49 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
50 playerStatus->actionSubstate = SUBSTATE_SLIDING;
51 playerStatus->curSpeed = 0.0f;
54 SlideAcceleration = 0.0f;
55 D_802B6790 = 0.0f;
56 D_802B6794 = 0.0f;
57 D_802B6798 = 0.0f;
58 D_802B679C = 0;
62 }
63 speed = playerStatus->curSpeed;
64 posX = playerStatus->pos.x;
65 posY = playerStatus->pos.y;
66 posZ = playerStatus->pos.z;
67 hitID = player_test_move_with_slipping(playerStatus, &posX, &posY, &posZ, speed, playerStatus->heading);
68 playerStatus->pos.x = posX;
69 playerStatus->pos.z = posZ;
70 playerStatus->pos.y = posY;
71
72 switch (playerStatus->actionSubstate) {
74 SlideAcceleration += 0.1;
77 }
78 playerStatus->curSpeed += SlideAcceleration;
79 if (MaxSlideVelocity <= playerStatus->curSpeed) {
80 playerStatus->curSpeed = MaxSlideVelocity;
81 }
82 posX = playerStatus->pos.x;
83 depth = 100.0f;
84 posZ = playerStatus->pos.z;
86 posY = playerStatus->pos.y + (playerStatus->colliderHeight * 0.5f);
87 hitID = player_raycast_below_cam_relative(playerStatus, &posX, &posY, &posZ, &depth, &hitRx, &hitRy, &hitDirX, &hitDirZ);
88 D_802B6798 = hitRy;
89 if (hitID > NO_COLLIDER) {
90 collisionStatus = &gCollisionStatus;
92 if (surfaceType == SURFACE_TYPE_SLIDE) {
93 collisionStatus->curFloor = hitID;
94 playerStatus->pos.y = posY;
95 D_802B6790 = hitRy + 180.0f;
96 break;
97 }
98 if (!(fabs(D_802B6794 - D_802B6798) >= 50.0)) {
99 playerStatus->actionSubstate = SUBSTATE_STOP;
100 } else {
101 playerStatus->actionSubstate = SUBSTATE_LAUNCH;
102 }
103 } else {
104 playerStatus->actionSubstate = SUBSTATE_LAUNCH;
105 }
106 sin_cos_rad(DEG_TO_RAD(D_802B6790), &sinA, &cosA);
107 playerStatus->pos.y += fabsf((sinA / cosA) * playerStatus->curSpeed);
109 break;
110 case SUBSTATE_STOP:
111 posX = playerStatus->pos.x;
112 depth = 50.0f;
113 posZ = playerStatus->pos.z;
114 posY = playerStatus->pos.y + (playerStatus->colliderHeight * 0.5f);
115 hitID = player_raycast_below_cam_relative(playerStatus, &posX, &posY, &posZ, &depth, &hitRx, &hitRy, &hitDirX, &hitDirZ);
116 if (hitID > NO_COLLIDER) {
117 speed = playerStatus->curSpeed / 3.0f;
118 if (speed < 0.01) {
119 playerStatus->curSpeed = 0.0f;
120 }
121 playerStatus->curSpeed -= speed;
122 if (playerStatus->curSpeed <= 0.0f) {
124 suggest_player_anim_always_forward(ANIM_Mario1_DustOff);
125 playerStatus->actionSubstate = SUBSTATE_DUST_OFF;
126 playerStatus->curStateTime = 15;
127 playerStatus->curSpeed = 0.0f;
128 playerStatus->pos.y = posY;
129 }
130 break;
131 }
132 case SUBSTATE_LAUNCH:
133 playerStatus->curSpeed += SlideLaunchSpeed;
134 if (playerStatus->curSpeed <= 0.0f) {
135 playerStatus->curSpeed = 0.0f;
136 }
137 playerStatus->gravityIntegrator[0] += playerStatus->gravityIntegrator[1];
138 playerStatus->pos.y += playerStatus->gravityIntegrator[0];
139 if (playerStatus->gravityIntegrator[0] <= 0.0f) {
140 playerStatus->actionSubstate = SUBSTATE_FALL;
142 }
143 break;
144 case SUBSTATE_FALL:
145 playerStatus->curSpeed += SlideLaunchSpeed;
146 if (playerStatus->curSpeed <= 0.0f) {
147 playerStatus->curSpeed = 0.0f;
148 }
149 playerStatus->pos.y = player_check_collision_below(player_fall_distance(), &hitID);
150 if (hitID > NO_COLLIDER) {
151 SlideLaunchSpeed = -1;
152 suggest_player_anim_always_forward(ANIM_MarioW2_Collapse);
154 playerStatus->actionSubstate++; // SUBSTATE_CRASH
155 }
156 break;
157 case SUBSTATE_CRASH:
158 playerStatus->curSpeed += SlideLaunchSpeed;
159 if (playerStatus->curSpeed <= 0.0f) {
160 playerStatus->curSpeed = 0.0f;
161 }
162 if (playerStatus->animNotifyValue != 0) {
163 suggest_player_anim_always_forward(ANIM_Mario1_GetUp);
164 playerStatus->actionSubstate++; // SUBSTATE_GET_UP
165 }
166 break;
167 case SUBSTATE_GET_UP:
168 playerStatus->curSpeed += SlideLaunchSpeed;
169 if (playerStatus->curSpeed <= 0.0f) {
170 playerStatus->curSpeed = 0.0f;
171 }
172 if (playerStatus->animNotifyValue != 0) {
173 suggest_player_anim_always_forward(ANIM_Mario1_DustOff);
175 playerStatus->curStateTime = 15;
176 playerStatus->actionSubstate++; // SUBSTATE_DUST_OFF
177 }
178 break;
180 playerStatus->curSpeed += SlideLaunchSpeed;
181 if (playerStatus->curSpeed <= 0.0f) {
182 playerStatus->curSpeed = 0.0f;
183 }
184 if (--playerStatus->curStateTime == 0) {
185 playerStatus->actionSubstate++; // SUBSTATE_DONE
186 }
187 break;
188 case SUBSTATE_DONE:
189 speed = playerStatus->curSpeed / 3.0f;
190 if (speed < 0.01) {
191 playerStatus->curSpeed = 0.0f;
192 }
193 playerStatus->curSpeed -= speed;
194 if (playerStatus->curSpeed <= 0.0f) {
195 playerStatus->curSpeed = 0.0f;
197 }
198 break;
199 }
200}
void snd_stop_sound(s32 soundID)
Definition 30450.c:256
@ SURFACE_TYPE_SLIDE
Definition enums.h:4675
@ PS_FLAG_ACTION_STATE_CHANGED
Definition enums.h:3084
@ COLLIDER_FLAGS_SURFACE_TYPE_MASK
Definition enums.h:4693
@ PA_FLAG_INTERRUPT_USE_PARTNER
forces actions with bow, parakarry, watt, and lakilester to end (sushie not tested)
Definition enums.h:3093
@ SOUND_SLIDE
Definition enums.h:789
@ SOUND_TRIP
Definition enums.h:784
@ SOUND_DUST_OFF
Definition enums.h:791
@ ACTION_STATE_IDLE
Definition enums.h:2426
@ CAMERA_MOVE_IGNORE_PLAYER_Y
Definition enums.h:4732
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737
@ CAM_DEFAULT
Definition enums.h:1800
f32 fabsf(f32 f)
f64 fabs(f64 f)
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
void suggest_player_anim_always_forward(AnimID anim)
Definition 77480.c:913
s32 get_collider_flags(s32 colliderID)
Definition collision.c:481
f32 player_check_collision_below(f32, s32 *colliderID)
Definition 7BB60.c:470
void set_action_state(s32 actionState)
Definition 7E9D0.c:209
HitID player_test_move_with_slipping(PlayerStatus *playerStatus, f32 *posX, f32 *posY, f32 *posZ, f32 speed, f32 heading)
Definition 77480.c:563
void suggest_player_anim_allow_backward(AnimID anim)
Definition 77480.c:894
void sin_cos_rad(f32 rad, f32 *outSinTheta, f32 *outCosTheta)
Definition 43F0.c:706
f32 player_fall_distance(void)
Definition 7BB60.c:461
void sfx_play_sound_at_player(s32 soundID, s32 arg1)
Definition sfx.c:521
#define DEG_TO_RAD(deg)
Definition macros.h:134
#define LOAD_INTEGRATOR_FALL(ptr)
Definition macros.h:186
#define NO_COLLIDER
Definition macros.h:156
BSS f32 SlideAcceleration
Definition slide.c:4
BSS f32 D_802B6798
Definition slide.c:10
BSS s32 D_802B679C
Definition slide.c:11
BSS f32 D_802B6790
Definition slide.c:8
BSS f32 D_802B6794
Definition slide.c:9
void func_802B6000_E27510(void)
Definition slide.c:24
CollisionStatus gCollisionStatus
Definition 7BB60.c:6
Camera gCameras[4]
Definition cam_main.c:17

Variable Documentation

◆ SlideAcceleration

BSS f32 SlideAcceleration

Definition at line 4 of file slide.c.

Referenced by action_update_sliding().

◆ MaxSlideAccel

BSS f32 MaxSlideAccel

Definition at line 5 of file slide.c.

Referenced by action_update_sliding(), and func_802B6000_E27510().

◆ MaxSlideVelocity

BSS f32 MaxSlideVelocity

Definition at line 6 of file slide.c.

Referenced by action_update_sliding(), and func_802B6000_E27510().

◆ SlideLaunchSpeed

BSS f32 SlideLaunchSpeed

Definition at line 7 of file slide.c.

Referenced by action_update_sliding(), and func_802B6000_E27510().

◆ D_802B6790

BSS f32 D_802B6790

Definition at line 8 of file slide.c.

Referenced by action_update_sliding().

◆ D_802B6794

BSS f32 D_802B6794

Definition at line 9 of file slide.c.

Referenced by action_update_sliding().

◆ D_802B6798

BSS f32 D_802B6798

Definition at line 10 of file slide.c.

Referenced by action_update_sliding().

◆ D_802B679C

BSS s32 D_802B679C

Definition at line 11 of file slide.c.

Referenced by action_update_sliding().