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

Go to the source code of this file.

Enumerations

enum  {
  SUBSTATE_ASCEND = 0 , SUBSTATE_HOVER = 1 , SUBSTATE_DESCEND = 2 , SUBSTATE_IMPACT = 3 ,
  SUBSTATE_HIT_SWITCH = 11 , SUBSTATE_DONE_SWITCH = 12
}
 

Functions

void phys_clear_spin_history (void)
 
void record_jump_apex (void)
 
void action_update_tornado_jump (void)
 

Variables

s32 gSpinHistoryBufferPos
 
s32 gSpinHistoryPosY [5]
 
s16 gSpinHistoryPosAngle [5]
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SUBSTATE_ASCEND 
SUBSTATE_HOVER 
SUBSTATE_DESCEND 
SUBSTATE_IMPACT 
SUBSTATE_HIT_SWITCH 
SUBSTATE_DONE_SWITCH 

Definition at line 11 of file tornado_jump.c.

11 {
18};
@ SUBSTATE_HOVER
@ SUBSTATE_DESCEND
@ SUBSTATE_IMPACT
@ SUBSTATE_HIT_SWITCH
@ SUBSTATE_DONE_SWITCH
@ SUBSTATE_ASCEND

Function Documentation

◆ phys_clear_spin_history()

void phys_clear_spin_history ( void )

Definition at line 71 of file 7E9D0.c.

71 {
72 s32 i;
73
75
76 for (i = 0; i < ARRAY_COUNT(gSpinHistoryPosAngle); i++) {
77 gSpinHistoryPosAngle[i] = 180;
78 gSpinHistoryPosY[i] = 0x80000000;
79 }
80}
s32 gSpinHistoryPosY[5]
Definition 7E9D0.c:27
s32 gSpinHistoryBufferPos
Definition 7E9D0.c:24
s16 gSpinHistoryPosAngle[5]
Definition 7E9D0.c:29
#define ARRAY_COUNT(arr)
Definition macros.h:40

Referenced by action_update_tornado_jump().

◆ record_jump_apex()

void record_jump_apex ( void )

◆ action_update_tornado_jump()

void action_update_tornado_jump ( void )

Definition at line 22 of file tornado_jump.c.

22 {
23 PlayerStatus* playerStatus = &gPlayerStatus;
24 CollisionStatus* collisionStatus = &gCollisionStatus;
25 f32 cameraRelativeYaw;
26 f32 fallVelocity;
27 s32 surfaceType;
28 f32 spinRate;
29 s32 colliderBelow;
30 u32 entityType;
31
32 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
33 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
36 playerStatus->actionSubstate = SUBSTATE_ASCEND;
37 playerStatus->curSpeed = 0.0f;
38 playerStatus->gravityIntegrator[0] = 16.0f;
39 playerStatus->gravityIntegrator[1] = -7.38624f;
40 playerStatus->gravityIntegrator[2] = 3.44694f;
41 playerStatus->gravityIntegrator[3] = -0.75f;
42 suggest_player_anim_always_forward(ANIM_MarioW2_Carried);
44 playerStatus->flags |= PS_FLAG_SPECIAL_JUMP;
46 cameraRelativeYaw = clamp_angle(playerStatus->targetYaw - gCameras[gCurrentCameraID].curYaw);
47 if (cameraRelativeYaw <= 180.0f) {
48 spinRate = 60.0f;
49 } else {
50 spinRate = -60.0f;
51 }
52 playerStatus->spinRate = spinRate;
53 }
54 if (playerStatus->actionSubstate <= SUBSTATE_IMPACT) {
55 if (playerStatus->spinRate >= 0.0f) {
56 playerStatus->spriteFacingAngle += playerStatus->spinRate;
57 if (playerStatus->spriteFacingAngle >= 360.0f) {
58 playerStatus->spriteFacingAngle -= 360.0f;
59 }
60 } else {
61 playerStatus->spriteFacingAngle += playerStatus->spinRate;
62 if (playerStatus->spriteFacingAngle < 0.0f) {
63 playerStatus->spriteFacingAngle += 360.0f;
64 }
65 }
66 }
67 if (playerStatus->gravityIntegrator[0] <= 0.0f) {
69 }
70
72
73 if (gSpinHistoryBufferPos >= 6) {
75 }
76
77 switch (playerStatus->actionSubstate) {
78 case SUBSTATE_ASCEND:
79 fallVelocity = integrate_gravity();
80 playerStatus->pos.y = player_check_collision_below(fallVelocity, &colliderBelow);
81 if (colliderBelow >= 0 && collisionStatus->curFloor & COLLISION_WITH_ENTITY_BIT ) {
82 entityType = get_entity_type(collisionStatus->curFloor);
83 if (entityType == ENTITY_TYPE_BLUE_SWITCH || entityType == ENTITY_TYPE_RED_SWITCH) {
86 playerStatus->actionSubstate = SUBSTATE_HIT_SWITCH;
87 break;
88 }
89 }
90 if (fallVelocity <= 0.0f) {
92 playerStatus->curStateTime = 3;
93 playerStatus->flags |= PS_FLAG_FALLING;
94 playerStatus->actionSubstate++;
96 }
97 if (colliderBelow >= 0) {
98 playerStatus->flags &= ~(PS_FLAG_SPINNING | PS_FLAG_FLYING);
100 }
101 break;
102 case SUBSTATE_HOVER:
103 if (--playerStatus->curStateTime <= 0) {
104 playerStatus->actionSubstate++;
105 }
106 break;
107 case SUBSTATE_DESCEND:
108 fallVelocity = integrate_gravity();
109 playerStatus->pos.y = player_check_collision_below(fallVelocity, &colliderBelow);
110 if (fallVelocity < -100.0f) {
111 playerStatus->gravityIntegrator[3] = 0.0f;
112 playerStatus->gravityIntegrator[2] = 0.0f;
113 playerStatus->gravityIntegrator[1] = 0.0f;
114 playerStatus->gravityIntegrator[0] = -100.0f;
115 }
116 if (colliderBelow > NO_COLLIDER) {
117 if (collisionStatus->curFloor & COLLISION_WITH_ENTITY_BIT) {
118 entityType = get_entity_type(collisionStatus->curFloor);
119 if (entityType == ENTITY_TYPE_SIMPLE_SPRING || entityType == ENTITY_TYPE_SCRIPT_SPRING) {
120 playerStatus->flags &= ~(PS_FLAG_SPINNING | PS_FLAG_FLYING);
122 return;
123 } else if (entityType == ENTITY_TYPE_BLUE_SWITCH || entityType == ENTITY_TYPE_RED_SWITCH) {
124 playerStatus->flags &= ~(PS_FLAG_SPINNING | PS_FLAG_FLYING);
126 exec_ShakeCam1(0, 0, 4);
128 start_rumble(256, 50);
129
132 playerStatus->flags |= PS_FLAG_SPECIAL_LAND;
133 return;
134 }
135 }
136
137 surfaceType = get_collider_flags(colliderBelow) & COLLIDER_FLAGS_SURFACE_TYPE_MASK;
138 if (surfaceType == SURFACE_TYPE_LAVA) {
139#if !VERSION_JP
140 playerStatus->hazardType = HAZARD_TYPE_LAVA;
141#endif
142 playerStatus->flags &= ~(PS_FLAG_SPINNING | PS_FLAG_FLYING);
144 playerStatus->flags |= PS_FLAG_HIT_FIRE;
145 return;
146 } else if (surfaceType == SURFACE_TYPE_SPIKES) {
148 playerStatus->flags &= ~(PS_FLAG_SPINNING | PS_FLAG_FLYING);
149 return;
150 }
151 playerStatus->curStateTime = 8;
152 playerStatus->timeInAir = 0;
154 playerStatus->actionSubstate++;
155 exec_ShakeCam1(0, 0, 4);
157 start_rumble(256, 50);
158
161 playerStatus->flags |= PS_FLAG_SPECIAL_LAND;
162 }
163 break;
164 case SUBSTATE_IMPACT:
165 if (--playerStatus->curStateTime == 0) {
166 playerStatus->actionSubstate++;
167 playerStatus->flags &= ~(PS_FLAG_SPINNING | PS_FLAG_FLYING);
169 }
170 break;
173 playerStatus->actionSubstate++;
175 break;
177 break;
178 }
179
180 if (playerStatus->gravityIntegrator[0] < 0.0f) {
181 colliderBelow = get_collider_below_tornado_jump();
182 if (colliderBelow >= 0) {
183 collisionStatus->lastTouchedFloor = -1;
184 collisionStatus->curFloor = colliderBelow;
185 }
186 }
187}
f32 gravityIntegrator[4]
#define clamp_angle
@ 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_SPINNING
Definition enums.h:3058
@ 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_SCRIPT_SPRING
Definition enums.h:2584
@ ENTITY_TYPE_BLUE_SWITCH
Definition enums.h:2550
@ ENTITY_TYPE_RED_SWITCH
Definition enums.h:2551
@ ENTITY_TYPE_SIMPLE_SPRING
Definition enums.h:2583
@ ENTITY_COLLISION_PLAYER_TOUCH_FLOOR
Definition enums.h:2648
@ SOUND_TORNADO_JUMP
Definition enums.h:764
@ SOUND_LAND_TORANDO_JUMP
Definition enums.h:767
@ ACTION_STATE_HIT_LAVA
Definition enums.h:2451
@ ACTION_STATE_LANDING_ON_SWITCH
Small red/blue ! switches.
Definition enums.h:2434
@ ACTION_STATE_TORNADO_POUND
Definition enums.h:2444
@ 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
void phys_player_land(void)
Definition 7BB60.c:369
void suggest_player_anim_always_forward(AnimID anim)
Definition 77480.c:913
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 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
s32 gSpinHistoryPosY[5]
Definition 7E9D0.c:27
void record_jump_apex(void)
Definition 7BB60.c:18
s32 gSpinHistoryBufferPos
Definition 7E9D0.c:24
s16 gSpinHistoryPosAngle[5]
Definition 7E9D0.c:29
void phys_clear_spin_history(void)
Definition 7E9D0.c:71
CollisionStatus gCollisionStatus
Definition 7BB60.c:6
Camera gCameras[4]
Definition cam_main.c:17
s32 gCurrentCameraID
Definition cam_math.c:4
HiddenPanelsData gCurrentHiddenPanels
Definition entity.c:36

Variable Documentation

◆ gSpinHistoryBufferPos

s32 gSpinHistoryBufferPos
extern

◆ gSpinHistoryPosY

s32 gSpinHistoryPosY[5]
extern

◆ gSpinHistoryPosAngle

s16 gSpinHistoryPosAngle[5]
extern