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

Go to the source code of this file.

Enumerations

enum  {
  SUBSTATE_SPIN = 0 , SUBSTATE_RISE = 2 , SUBSTATE_HOVER = 3 , SUBSTATE_DESCEND = 4 ,
  SUBSTATE_IMPACT = 5 , SUBSTATE_HOLD = 6 , SUBSTATE_ABORT = 7 , SUBSTATE_HIT_SWITCH = 11 ,
  SUBSTATE_DONE_SWITCH = 12
}
 

Functions

void action_update_spin_jump (void)
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SUBSTATE_SPIN 
SUBSTATE_RISE 
SUBSTATE_HOVER 
SUBSTATE_DESCEND 
SUBSTATE_IMPACT 
SUBSTATE_HOLD 
SUBSTATE_ABORT 
SUBSTATE_HIT_SWITCH 
SUBSTATE_DONE_SWITCH 

Definition at line 4 of file spin_jump.c.

4 {
10 SUBSTATE_HOLD = 6,
14};
@ SUBSTATE_HOLD
Definition spin_jump.c:10
@ SUBSTATE_HOVER
Definition spin_jump.c:7
@ SUBSTATE_DESCEND
Definition spin_jump.c:8
@ SUBSTATE_IMPACT
Definition spin_jump.c:9
@ SUBSTATE_HIT_SWITCH
Definition spin_jump.c:12
@ SUBSTATE_DONE_SWITCH
Definition spin_jump.c:13
@ SUBSTATE_RISE
Definition spin_jump.c:6
@ SUBSTATE_SPIN
Definition spin_jump.c:5
@ SUBSTATE_ABORT
Definition spin_jump.c:11

Function Documentation

◆ action_update_spin_jump()

void action_update_spin_jump ( void )

Definition at line 18 of file spin_jump.c.

18 {
19 PlayerStatus* playerStatus = &gPlayerStatus;
20 CollisionStatus* collisionStatus = &gCollisionStatus;
21 HiddenPanelsData* panels;
22 Entity* entity;
23 s32 belowColliderID;
24 s32 landed;
25 f32 velocity;
26 u32 entityType;
27 s32 surfaceType;
28
29 static f32 RotationRate;
30
31 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
33 playerStatus->flags |= (PS_FLAG_JUMPING | PS_FLAG_FLYING);
34
35 playerStatus->actionSubstate = SUBSTATE_SPIN;
36 playerStatus->curSpeed = 0.0f;
37 RotationRate = 0.0f;
38 playerStatus->gravityIntegrator[0] = 5.2f;
41 playerStatus->flags |= PS_FLAG_SPECIAL_JUMP;
44 }
45
46 landed = FALSE;
47 switch (playerStatus->actionSubstate) {
48 case SUBSTATE_SPIN:
49 RotationRate = 40.0f;
50 playerStatus->pitch += RotationRate;
51 if (playerStatus->pitch >= 360.0f) {
52 playerStatus->pitch = 360.0f;
53 }
54 if (playerStatus->gravityIntegrator[0] >= 0.0f) {
55 playerStatus->gravityIntegrator[0] -= 0.54;
56 if (collisionStatus->curCeiling < 0) {
57 playerStatus->pos.y += playerStatus->gravityIntegrator[0];
58 } else if (collisionStatus->curCeiling & COLLISION_WITH_ENTITY_BIT) {
59 entity = get_entity_by_index(collisionStatus->curCeiling);
60 if (entity != NULL) {
61 playerStatus->pos.y = entity->pos.y - (playerStatus->colliderHeight * 0.5);
62 }
63 }
64 }
65 if (playerStatus->pitch == 360.0f) {
66 if (playerStatus->gravityIntegrator[0] <= 0.0f) {
67 playerStatus->curStateTime = 5;
68 playerStatus->actionSubstate = SUBSTATE_RISE;
69 playerStatus->gravityIntegrator[0] = 2.0f;
70 }
71 }
72 collisionStatus->curCeiling = -1;
73 break;
74 case SUBSTATE_RISE:
75 if (playerStatus->gravityIntegrator[0] >= 0.0f) {
76 playerStatus->gravityIntegrator[0] -= 1.4;
77 if (collisionStatus->curCeiling < 0) {
78 playerStatus->pos.y += playerStatus->gravityIntegrator[0];
79 }
80 }
81 if (--playerStatus->curStateTime <= 0) {
82 playerStatus->actionSubstate++;
83 }
84 break;
85 case SUBSTATE_HOVER:
86 playerStatus->pos.y = player_check_collision_below(0.0f, &belowColliderID);
87 RotationRate = 45.0f;
88 playerStatus->pitch += RotationRate;
89 if (playerStatus->pitch >= 360.0) {
90 playerStatus->pitch = 0.0f;
91 playerStatus->actionSubstate++;
92 playerStatus->gravityIntegrator[1] = -3.4744f;
93 playerStatus->gravityIntegrator[2] = 0.4704f;
94 playerStatus->gravityIntegrator[3] = -1.1904f;
95 playerStatus->gravityIntegrator[0] = playerStatus->gravityIntegrator[1];
96 suggest_player_anim_allow_backward(ANIM_Mario1_SpinJump);
97 }
98 break;
100 velocity = player_fall_distance();
101 playerStatus->pos.y = player_check_collision_below(velocity, &belowColliderID);
102 if (velocity < -100.0f) {
103 playerStatus->gravityIntegrator[3] = 0.0f;
104 playerStatus->gravityIntegrator[2] = 0.0f;
105 playerStatus->gravityIntegrator[1] = 0.0f;
106 playerStatus->gravityIntegrator[0] = -100.0f;
107 }
108 if (belowColliderID > NO_COLLIDER) {
109 if (collisionStatus->curFloor & COLLISION_WITH_ENTITY_BIT && (entityType = get_entity_type(collisionStatus->curFloor),
110 entityType == ENTITY_TYPE_RED_SWITCH || entityType == ENTITY_TYPE_BLUE_SWITCH)) {
112 playerStatus->actionSubstate = SUBSTATE_HIT_SWITCH;
113 playerStatus->flags &= ~PS_FLAG_FLYING;
114 break;
115 } else {
116 surfaceType = get_collider_flags(belowColliderID) & COLLIDER_FLAGS_SURFACE_TYPE_MASK;
117 if (surfaceType == SURFACE_TYPE_LAVA) {
118#if !VERSION_JP
119 playerStatus->hazardType = HAZARD_TYPE_LAVA;
120#endif
122 playerStatus->flags |= PS_FLAG_HIT_FIRE;
123 playerStatus->flags &= ~PS_FLAG_FLYING;
124 return;
125 } else if (surfaceType == SURFACE_TYPE_SPIKES) {
127 playerStatus->flags &= ~PS_FLAG_FLYING;
128 return;
129 } else {
130 playerStatus->gravityIntegrator[1] = -3.4744f;
131 playerStatus->gravityIntegrator[2] = 0.4704f;
132 playerStatus->gravityIntegrator[3] = -1.1904f;
133 playerStatus->gravityIntegrator[0] = 10.0f;
134 suggest_player_anim_allow_backward(ANIM_Mario1_SpinJump);
135 playerStatus->actionState = ACTION_STATE_SPIN_POUND;
136 playerStatus->timeInAir = 0;
137 playerStatus->poundImpactDelay = 12;
138 playerStatus->pitch = 0.0f;
139 playerStatus->actionSubstate++;
140 exec_ShakeCam1(0, 0, 4);
142 start_rumble(128, 25);
143 panels = &gCurrentHiddenPanels;
144 panels->tryFlipTrigger = TRUE;
145 panels->flipTriggerPosY = playerStatus->pos.y;
146 playerStatus->flags |= PS_FLAG_SPECIAL_LAND;
147 }
148 }
149 }
150 break;
151 case SUBSTATE_IMPACT:
152 velocity = integrate_gravity();
153 if (velocity == 0.0f) {
154 landed = TRUE;
155 } else {
156 if (playerStatus->gravityIntegrator[0] > 0.0f) {
157 playerStatus->pos.y += velocity;
158 } else {
159 playerStatus->pos.y = player_check_collision_below(velocity, &belowColliderID);
160 if (playerStatus->gravityIntegrator[0] < 0.0f && belowColliderID >= 0) {
161 playerStatus->actionSubstate++;
162 }
163 }
164 playerStatus->pos.y = player_check_collision_below(0.0f, &belowColliderID);
165 }
166 break;
167 case SUBSTATE_HOLD:
168 playerStatus->pos.y = player_check_collision_below(0.0f, &belowColliderID);
169 if (belowColliderID >= 0) {
170 playerStatus->gravityIntegrator[0] = 0.0f;
171 playerStatus->gravityIntegrator[1] = 0.0f;
172 playerStatus->gravityIntegrator[2] = 0.0f;
173 playerStatus->gravityIntegrator[3] = 0.0f;
174 }
175 // fallthrough
176 case SUBSTATE_ABORT:
177 if (--playerStatus->poundImpactDelay <= 0) {
178 landed = TRUE;
179 }
180 break;
183 playerStatus->actionSubstate++;
185 break;
187 break;
188 }
189
190 if (landed) {
192 playerStatus->flags &= ~PS_FLAG_FLYING;
193 }
194 if (playerStatus->gravityIntegrator[0] < 0.0f) {
195 belowColliderID = get_collider_below_spin_jump();
196 if (belowColliderID >= 0) {
197 collisionStatus->lastTouchedFloor = -1;
198 collisionStatus->curFloor = belowColliderID;
199 }
200 }
201}
f32 gravityIntegrator[4]
@ 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_SPECIAL_JUMP
Definition enums.h:3046
@ PS_FLAG_FLYING
Definition enums.h:3037
@ PS_FLAG_HIT_FIRE
Definition enums.h:3050
@ PS_FLAG_SPECIAL_LAND
Definition enums.h:3048
@ COLLIDER_FLAGS_SURFACE_TYPE_MASK
Definition enums.h:4693
@ HAZARD_TYPE_LAVA
Definition enums.h:3500
@ ENTITY_TYPE_BLUE_SWITCH
Definition enums.h:2550
@ ENTITY_TYPE_RED_SWITCH
Definition enums.h:2551
@ ENTITY_COLLISION_PLAYER_TOUCH_FLOOR
Definition enums.h:2648
@ SOUND_LAND_SPIN_JUMP
Definition enums.h:766
@ SOUND_SPIN_JUMP
Definition enums.h:763
@ ACTION_STATE_HIT_LAVA
Definition enums.h:2451
@ ACTION_STATE_SPIN_POUND
Definition enums.h:2442
@ ACTION_STATE_LANDING_ON_SWITCH
Small red/blue ! switches.
Definition enums.h:2434
@ ACTION_STATE_LAND
Definition enums.h:2437
@ CAMERA_MOVE_IGNORE_PLAYER_Y
Definition enums.h:4732
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737
@ CAM_DEFAULT
Definition enums.h:1800
void start_rumble(s32, s32)
Definition rumble.c:15
Entity * get_entity_by_index(s32 index)
Definition entity.c:530
f32 integrate_gravity(void)
Definition 7BB60.c:436
s32 disable_player_input(void)
Definition 77480.c:990
s32 get_collider_flags(s32 colliderID)
Definition collision.c:481
f32 player_check_collision_below(f32, s32 *colliderID)
Definition 7BB60.c:470
s32 enable_player_input(void)
Definition 77480.c:998
u32 get_entity_type(s32 arg0)
Definition entity.c:568
void set_action_state(s32 actionState)
Definition 7E9D0.c:209
void exec_ShakeCam1(s32 arg0, s32 arg1, s32 arg2)
Definition cam_api.c:365
void suggest_player_anim_allow_backward(AnimID anim)
Definition 77480.c:894
f32 player_fall_distance(void)
Definition 7BB60.c:461
void sfx_play_sound_at_player(s32 soundID, s32 arg1)
Definition sfx.c:521
#define COLLISION_WITH_ENTITY_BIT
Definition macros.h:152
#define NO_COLLIDER
Definition macros.h:156
u8 collisionFlags
CollisionStatus gCollisionStatus
Definition 7BB60.c:6
Camera gCameras[4]
Definition cam_main.c:17
PlayerStatus gPlayerStatus
Definition 77480.c:39
HiddenPanelsData gCurrentHiddenPanels
Definition entity.c:36