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

Go to the source code of this file.

Macros

#define ACTION_FILE(name)   world_action_##name##_ROM_START, world_action_##name##_ROM_END
 

Functions

void action_update_idle (void)
 
void action_update_walk (void)
 
void action_update_run (void)
 
void action_update_land (void)
 
void action_update_jump (void)
 
void action_update_landing_on_switch (void)
 
void action_update_falling (void)
 
void action_update_step_down (void)
 
void action_update_step_down_land (void)
 
void action_update_spin_jump (void)
 
void action_update_tornado_jump (void)
 
void action_update_talk (void)
 
void action_update_sliding (void)
 
void action_update_hammer (void)
 
void action_update_launch (void)
 
void action_update_pushing_block (void)
 
void action_update_hit_fire (void)
 
void action_update_knockback (void)
 
void action_update_hit_lava (void)
 
void action_update_parasol (void)
 
void action_update_spin (void)
 
void action_update_step_up_peach (void)
 
void action_update_ride (void)
 
void action_update_step_up (void)
 
void action_update_first_strike (void)
 
void action_update_raise_arms (void)
 
void action_update_use_spinning_flower (void)
 
void action_update_use_munchlesia (void)
 
void action_update_use_tweester (void)
 
void action_update_state_23 (void)
 

Variables

Action PlayerActionsTable []
 

Macro Definition Documentation

◆ ACTION_FILE

#define ACTION_FILE ( name)    world_action_##name##_ROM_START, world_action_##name##_ROM_END

Definition at line 75 of file actions.c.

Function Documentation

◆ action_update_idle()

void action_update_idle ( void )

Definition at line 36 of file idle.c.

36 {
37 PlayerStatus* playerStatus = &gPlayerStatus;
38 PlayerData* playerData = &gPlayerData;
39 s32 firstFrame = FALSE;
40 f32 angle, magnitude;
41 AnimID anim;
42
43 if (playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS) {
45 return;
46 }
47
48 playerStatus->curStateTime++;
49
50 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
52 firstFrame = TRUE;
54 playerStatus->curStateTime = 0;
55 playerStatus->timeInAir = 0;
56 playerStatus->peakJumpTime = 0;
57 playerStatus->curSpeed = 0.0f;
58 playerStatus->pitch = 0.0f;
59
60 if (playerStatus->animFlags & PA_FLAG_8BIT_MARIO) {
61 anim = ANIM_MarioW3_8bit_Still;
62 } else if (!(playerStatus->animFlags & PA_FLAG_USING_WATT)) {
63 anim = ANIM_Mario1_Idle;
64 } else if (playerStatus->prevActionState == ACTION_STATE_IDLE) {
65 anim = ANIM_MarioW1_TakeItem;
66 } else {
67 anim = ANIM_MarioW1_CarryIdle;
68 }
70 }
71
72 if (playerStatus->animFlags & PA_FLAG_RAISED_ARMS) {
74 return;
75 }
76
77 player_input_to_move_vector(&angle, &magnitude);
79
80 if (check_input_jump()) {
81 if (magnitude != 0.0f || playerStatus->targetYaw != angle) {
82 playerStatus->targetYaw = angle;
83 }
84 return;
85 }
86
87 if (!firstFrame && check_input_hammer()) {
88 return;
89 }
90
91 if (magnitude == 0.0f) {
92 playerData->idleFrameCounter++;
93 } else {
94 playerStatus->curStateTime = 0;
96 if (magnitude != 0.0f) {
97 playerStatus->targetYaw = angle;
98 playerStatus->animFlags &= ~PA_FLAG_80000000;
99 }
100 }
101}
u32 AnimID
@ PS_FLAG_ACTION_STATE_CHANGED
Definition enums.h:3084
@ PS_FLAG_ARMS_RAISED
Definition enums.h:3063
@ PS_FLAG_AIRBORNE
Definition enums.h:3033
@ PA_FLAG_RAISED_ARMS
Sets action state to ACTION_STATE_RAISE_ARMS on idle.
Definition enums.h:3100
@ 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
@ ACTION_STATE_IDLE
Definition enums.h:2426
@ ACTION_STATE_RAISE_ARMS
Definition enums.h:2456
@ ACTION_STATE_WALK
Definition enums.h:2427
void player_input_to_move_vector(f32 *angle, f32 *magnitude)
Definition 7B440.c:140
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_hammer(void)
Definition 7E9D0.c:321
b32 check_input_jump(void)
Definition 7E9D0.c:344
@ SUBSTATE_IDLE_DEFAULT
Definition idle.c:28
void action_update_idle_peach(void)
Definition idle.c:103
PlayerData gPlayerData
Definition 77480.c:40
PlayerStatus gPlayerStatus
Definition 77480.c:39

◆ action_update_walk()

void action_update_walk ( void )

Definition at line 30 of file walk.c.

30 {
31 PlayerStatus* playerStatus = &gPlayerStatus;
32 PlayerData* playerData = &gPlayerData;
33 b32 firstFrame = FALSE;
34 f32 moveMag;
35 f32 moveAngle;
36 AnimID anim;
37
38 if (playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS) {
39 action_update_walk_peach();
40 return;
41 }
42
43 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
45 playerStatus->unk_60 = 0;
46 firstFrame = TRUE;
47
48 if (!(playerStatus->flags & PS_FLAG_CUTSCENE_MOVEMENT)) {
49 playerStatus->curSpeed = playerStatus->walkSpeed;
50 }
51
52 if (playerStatus->animFlags & PA_FLAG_8BIT_MARIO) {
53 anim = ANIM_MarioW3_8bit_Run;
54 } else if (!(playerStatus->animFlags & PA_FLAG_USING_WATT)) {
55 anim = ANIM_Mario1_Walk;
56 } else {
57 anim = ANIM_MarioW1_CarryWalk;
58 }
60 }
61
62 if (playerStatus->flags & PS_FLAG_CUTSCENE_MOVEMENT) {
63 playerStatus->targetYaw = playerStatus->heading;
65 return;
66 }
67
68 player_input_to_move_vector(&moveAngle, &moveMag);
70
71 if (check_input_jump()) {
72 return;
73 }
74
75 if (!firstFrame && check_input_hammer()) {
76 return;
77 }
78
79 player_input_to_move_vector(&moveAngle, &moveMag);
80 if (moveMag == 0.0f) {
82 return;
83 }
84
85 if (fabsf(PrevPlayerCamRelativeYaw - moveAngle) <= 90.0f && abs(moveMag - D_800F7B44) < 20) {
86 if (!(playerStatus->animFlags & PA_FLAG_80000000)) {
87 if (moveMag >= 20.0f) {
88 playerStatus->targetYaw = moveAngle;
89 }
90 }
91 playerStatus->animFlags &= ~PA_FLAG_80000000;
92 } else {
93 if (playerStatus->animFlags & PA_FLAG_80000000) {
94 playerStatus->targetYaw = moveAngle;
95 } else {
96 playerStatus->animFlags |= PA_FLAG_80000000;
97 }
98 }
99
101 if (SQ(playerStatus->stickAxis[0]) + SQ(playerStatus->stickAxis[1]) > SQ(55)) {
103 return;
104 }
105 }
106
108 playerData->walkingStepsTaken++;
109}
s32 b32
@ PS_FLAG_CUTSCENE_MOVEMENT
Definition enums.h:3054
@ PS_FLAG_SCRIPTED_FALL
Definition enums.h:3071
@ PA_FLAG_80000000
Definition enums.h:3127
@ ABILITY_SLOW_GO
Definition enums.h:447
@ ACTION_STATE_RUN
Definition enums.h:2428
s32 is_ability_active(s32 arg0)
Definition inventory.c:1725
f32 fabsf(f32 f)
void try_player_footstep_sounds(s32 arg0)
Definition 7BB60.c:1105
#define SQ(x)
Definition macros.h:166
s32 D_800F7B44
Definition 7E9D0.c:32
s32 PrevPlayerCamRelativeYaw
Definition 7E9D0.c:31

◆ action_update_run()

void action_update_run ( void )

Definition at line 111 of file walk.c.

111 {
112 PlayerStatus* playerStatus = &gPlayerStatus;
113 PlayerData* playerData = &gPlayerData;
114 b32 firstFrame = FALSE;
115 f32 moveAngle;
116 f32 moveMag;
117 AnimID anim;
118 f32 runSpeedModifier;
119
120 if (playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS) {
121 action_update_run_peach();
122 return;
123 }
124
125 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
128 playerStatus->unk_60 = 0;
129 firstFrame = TRUE;
130
131 if (!(playerStatus->flags & PS_FLAG_CUTSCENE_MOVEMENT)) {
132 playerStatus->curSpeed = playerStatus->runSpeed;
133 }
134
135 if (playerStatus->animFlags & PA_FLAG_8BIT_MARIO) {
136 anim = ANIM_MarioW3_8bit_Run;
137 } else if (!(playerStatus->animFlags & PA_FLAG_USING_WATT)) {
138 anim = ANIM_Mario1_Run;
139 } else {
140 anim = ANIM_MarioW1_CarryRun;
141 }
143 }
144
145 if (playerStatus->flags & PS_FLAG_CUTSCENE_MOVEMENT) {
146 playerStatus->targetYaw = playerStatus->heading;
148 return;
149 }
150
152 runSpeedModifier = 1.0f;
153
154 if (playerStatus->animFlags & PA_FLAG_SPINNING) {
155 runSpeedModifier = 1.5f;
156 }
157
158 playerStatus->curSpeed = playerStatus->runSpeed * runSpeedModifier;
159 player_input_to_move_vector(&moveAngle, &moveMag);
161
162 if (check_input_jump()) {
163 return;
164 }
165
166 if (!firstFrame && check_input_hammer()) {
167 return;
168 }
169
170 player_input_to_move_vector(&moveAngle, &moveMag);
171 if (moveMag == 0.0f) {
173 return;
174 }
175
176 if (fabsf(PrevPlayerCamRelativeYaw - moveAngle) <= 90.0f) {
177 if (!(playerStatus->animFlags & PA_FLAG_80000000)) {
178 playerStatus->targetYaw = moveAngle;
179 }
180 playerStatus->animFlags &= ~PA_FLAG_80000000;
181 } else {
182 if (playerStatus->animFlags & PA_FLAG_80000000) {
183 playerStatus->targetYaw = moveAngle;
184 } else {
185 playerStatus->animFlags |= PA_FLAG_80000000;
186 }
187 }
188
190 if (sqrtf(SQ(playerStatus->stickAxis[0]) + SQ(playerStatus->stickAxis[1])) <= 55.0f) {
192 return;
193 }
194 } else {
196 return;
197 }
199 playerData->runningStepsTaken++;
200}
#define sqrtf
@ PA_FLAG_SPINNING
Definition enums.h:3107
s32 PlayerRunStateTime
Definition 7B440.c:8

◆ action_update_land()

void action_update_land ( void )

Definition at line 12 of file land.c.

12 {
13 CollisionStatus* collisionStatus = &gCollisionStatus;
14 PlayerStatus* playerStatus = &gPlayerStatus;
15 Camera* camera = &gCameras[CAM_DEFAULT];
16 f32 inputMoveMagnitude;
17 f32 inputMoveAngle;
18 s32 jumpInputCheck;
19 AnimID anim;
20
21 if (playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS) {
23 return;
24 }
25
26 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
27 playerStatus->flags &= ~(
32 );
33 playerStatus->actionSubstate = SUBSTATE_INIT;
34 playerStatus->timeInAir = 0;
35 playerStatus->peakJumpTime = 0;
36 playerStatus->landPos.x = playerStatus->pos.x;
37 playerStatus->landPos.z = playerStatus->pos.z;
38
39 if (playerStatus->animFlags & PA_FLAG_8BIT_MARIO) {
40 anim = ANIM_MarioW3_8bit_Still;
41 } else if (!(playerStatus->animFlags & PA_FLAG_USING_WATT)) {
42 anim = ANIM_Mario1_Land;
43 } else {
44 anim = ANIM_MarioW1_LandWatt;
45 }
46
50
51 if (!(collisionStatus->curFloor & COLLISION_WITH_ENTITY_BIT)) {
53 }
54
55 collisionStatus->lastTouchedFloor = -1;
56 playerStatus->animFlags &= ~PA_FLAG_INTERRUPT_SPIN;
57 camera->moveFlags &= ~CAMERA_MOVE_ACCEL_INTERP_Y;
58 }
59 playerStatus->actionSubstate++; // SUBSTATE_DONE
60 playerStatus->curSpeed *= 0.6f;
61
62 player_input_to_move_vector(&inputMoveAngle, &inputMoveMagnitude);
63 jumpInputCheck = check_input_jump();
64
65 if (jumpInputCheck != 0 || jumpInputCheck < playerStatus->actionSubstate) {
66 if (inputMoveMagnitude == 0.0f) {
68 return;
69 }
70 if (inputMoveMagnitude != 0.0f) {
71 playerStatus->targetYaw = inputMoveAngle;
72 }
74 }
75}
@ SOUND_ID_STOP
Definition enums.h:526
@ SOUND_LAND_SOFTLY
Definition enums.h:765
@ SOUND_PLAYER_LONG_FALL
Definition enums.h:783
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737
@ CAM_DEFAULT
Definition enums.h:1800
void update_locomotion_state(void)
Definition 7E9D0.c:281
s32 phys_adjust_cam_on_landing(void)
Definition 7E9D0.c:46
@ SUBSTATE_INIT
Definition land.c:5
void action_update_peach_land(void)
Definition land.c:121
void sfx_play_sound_at_player(s32 soundID, s32 arg1)
Definition sfx.c:521
#define COLLISION_WITH_ENTITY_BIT
Definition macros.h:152
CollisionStatus gCollisionStatus
Definition 7BB60.c:6
Camera gCameras[4]
Definition cam_main.c:17

◆ action_update_jump()

void action_update_jump ( void )

Definition at line 41 of file jump.c.

41 {
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}
@ PA_FLAG_WATT_IN_HANDS
Definition enums.h:3092
@ 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
void initialize_jump(void)
Definition jump.c:12

Referenced by action_update_step_down().

◆ action_update_landing_on_switch()

void action_update_landing_on_switch ( void )

Definition at line 76 of file jump.c.

76 {
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}
@ JUMP_SUBSTATE_1
Definition enums.h:2471
@ PS_FLAG_FALLING
Definition enums.h:3036
@ PS_FLAG_JUMPING
Definition enums.h:3035
@ PS_FLAG_FLYING
Definition enums.h:3037
Entity * get_entity_by_index(s32 index)
Definition entity.c:530
s32 disable_player_input(void)
Definition 77480.c:990
f32 JumpedOnSwitchZ
Definition 7BB60.c:8
f32 JumpedOnSwitchX
Definition 7BB60.c:7

◆ action_update_falling()

void action_update_falling ( void )

Definition at line 114 of file jump.c.

114 {
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}
void action_update_peach_falling(void)
Definition jump.c:177

◆ action_update_step_down()

void action_update_step_down ( void )

Definition at line 141 of file jump.c.

141 {
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}
@ SURFACE_TYPE_LAVA
Definition enums.h:4673
@ SURFACE_TYPE_SPIKES
Definition enums.h:4672
@ COLLIDER_FLAGS_SURFACE_TYPE_MASK
Definition enums.h:4693
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 get_collider_flags(s32 colliderID)
Definition collision.c:481
void action_update_peach_step_down(void)
Definition jump.c:198
void action_update_jump(void)
Definition jump.c:41

◆ action_update_step_down_land()

void action_update_step_down_land ( void )

Definition at line 77 of file land.c.

77 {
78 CollisionStatus* collisionStatus = &gCollisionStatus;
79 PlayerStatus* playerStatus = &gPlayerStatus;
80 f32 inputMoveMagnitude;
81 f32 inputMoveAngle;
82
83 if (playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS) {
85 return;
86 }
87
88 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
89 playerStatus->flags &= ~(
94 );
95 playerStatus->actionSubstate = SUBSTATE_INIT;
96 playerStatus->timeInAir = 0;
97 playerStatus->peakJumpTime = 0;
98 playerStatus->landPos.x = playerStatus->pos.x;
99 playerStatus->landPos.z = playerStatus->pos.z;
100
101 if (!(collisionStatus->curFloor & COLLISION_WITH_ENTITY_BIT)) {
103 }
104
105 collisionStatus->lastTouchedFloor = -1;
106 }
107
108 playerStatus->actionSubstate++; // SUBSTATE_DONE
109 playerStatus->curSpeed *= 0.6f;
110
111 player_input_to_move_vector(&inputMoveAngle, &inputMoveMagnitude);
113
114 if (inputMoveMagnitude != 0.0f) {
115 playerStatus->targetYaw = inputMoveAngle;
116 }
117
119}
void action_update_peach_step_down_land(void)
Definition land.c:165

◆ 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]
@ PS_FLAG_SPECIAL_JUMP
Definition enums.h:3046
@ PS_FLAG_HIT_FIRE
Definition enums.h:3050
@ PS_FLAG_SPECIAL_LAND
Definition enums.h:3048
@ 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
void start_rumble(s32, s32)
Definition rumble.c:15
f32 integrate_gravity(void)
Definition 7BB60.c:436
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 exec_ShakeCam1(s32 arg0, s32 arg1, s32 arg2)
Definition cam_api.c:365
f32 player_fall_distance(void)
Definition 7BB60.c:461
#define NO_COLLIDER
Definition macros.h:156
@ 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
u8 collisionFlags
HiddenPanelsData gCurrentHiddenPanels
Definition entity.c:36

◆ 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}
#define clamp_angle
@ PS_FLAG_SPINNING
Definition enums.h:3058
@ ENTITY_TYPE_SCRIPT_SPRING
Definition enums.h:2584
@ ENTITY_TYPE_SIMPLE_SPRING
Definition enums.h:2583
@ SOUND_TORNADO_JUMP
Definition enums.h:764
@ SOUND_LAND_TORANDO_JUMP
Definition enums.h:767
@ ACTION_STATE_TORNADO_POUND
Definition enums.h:2444
void phys_player_land(void)
Definition 7BB60.c:369
void suggest_player_anim_always_forward(AnimID anim)
Definition 77480.c:913
s32 gSpinHistoryPosY[5]
Definition 7E9D0.c:27
@ SUBSTATE_HOVER
@ SUBSTATE_DESCEND
@ SUBSTATE_IMPACT
@ SUBSTATE_HIT_SWITCH
@ SUBSTATE_DONE_SWITCH
@ SUBSTATE_ASCEND
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
s32 gCurrentCameraID
Definition cam_math.c:4

◆ action_update_talk()

void action_update_talk ( void )

Definition at line 214 of file misc.c.

214 {
215 PlayerStatus* playerStatus = &gPlayerStatus;
216
217 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
218 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
219 playerStatus->curSpeed = 0.0f;
220 playerStatus->unk_60 = 0;
221
222 if (!(playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS)) {
223 suggest_player_anim_always_forward(ANIM_MarioW2_SpeakUp);
224 } else if (playerStatus->peachItemHeld == PEACH_BAKING_NONE) {
225 if (!(playerStatus->animFlags & PA_FLAG_INVISIBLE)) {
226 suggest_player_anim_always_forward(ANIM_Peach2_RaiseArms);
227 } else {
229 }
230 }
231 playerStatus->curStateTime = 30;
232 }
233
234 if (playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS) {
235 if (playerStatus->curStateTime != 0) {
236 playerStatus->curStateTime--;
237 } else if (playerStatus->peachItemHeld == PEACH_BAKING_NONE) {
238 if (!(playerStatus->animFlags & PA_FLAG_INVISIBLE)) {
239 suggest_player_anim_always_forward(ANIM_Peach1_Idle);
240 } else {
242 }
243 }
244 }
245}
DisguiseAnims BasicPeachDisguiseAnims[]
Definition 7E9D0.c:464
@ PA_FLAG_INVISIBLE
Definition enums.h:3104
@ PEACH_BAKING_NONE
Definition enums.h:2496
void peach_set_disguise_anim(AnimID)
Definition 7E9D0.c:506

◆ 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
@ 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
f64 fabs(f64 f)
HitID player_test_move_with_slipping(PlayerStatus *playerStatus, f32 *posX, f32 *posY, f32 *posZ, f32 speed, f32 heading)
Definition 77480.c:563
void sin_cos_rad(f32 rad, f32 *outSinTheta, f32 *outCosTheta)
Definition 43F0.c:706
#define DEG_TO_RAD(deg)
Definition macros.h:134
#define LOAD_INTEGRATOR_FALL(ptr)
Definition macros.h:186
BSS f32 SlideAcceleration
Definition slide.c:4
BSS f32 D_802B6798
Definition slide.c:10
BSS f32 SlideLaunchSpeed
Definition slide.c:7
@ 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
BSS s32 D_802B679C
Definition slide.c:11
BSS f32 MaxSlideAccel
Definition slide.c:5
BSS f32 D_802B6790
Definition slide.c:8
BSS f32 MaxSlideVelocity
Definition slide.c:6
BSS f32 D_802B6794
Definition slide.c:9
void func_802B6000_E27510(void)
Definition slide.c:24

◆ action_update_hammer()

void action_update_hammer ( void )

Definition at line 230 of file hammer.c.

230 {
231 PlayerStatus* playerStatus = &gPlayerStatus;
232
233 HammerHit->unk_1C = 0;
234
235 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
236 AnimID anim;
237 s32 soundID;
238
239 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
240 playerStatus->flags |= PS_FLAG_NO_FLIPPING;
241 HammerHit->timer = 0;
242 playerStatus->actionSubstate = SUBSTATE_HAMMER_0;
243 playerStatus->curSpeed = 0.0f;
244 playerStatus->animNotifyValue = 0;
246
247 if (gPlayerData.hammerLevel == 2) {
248 soundID = SOUND_HAMMER_SWING_3;
249 anim = ANIM_MarioW1_Smash3_Hit;
250 if (HammerHit->hitID <= NO_COLLIDER) {
251 soundID = SOUND_HAMMER_SWING_3;
252 anim = ANIM_MarioW1_Smash3_Miss;
253 }
254 } else if (gPlayerData.hammerLevel == 1) {
255 soundID = SOUND_HAMMER_SWING_2;
256 anim = ANIM_MarioW1_Smash2_Hit;
257 if (HammerHit->hitID <= NO_COLLIDER) {
258 soundID = SOUND_HAMMER_SWING_2;
259 anim = ANIM_MarioW1_Smash2_Miss;
260 }
261 } else {
262 soundID = SOUND_HAMMER_SWING_1;
263 anim = ANIM_MarioW1_Smash1_Hit;
264 if (HammerHit->hitID <= NO_COLLIDER) {
265 soundID = SOUND_HAMMER_SWING_1;
266 anim = ANIM_MarioW1_Smash1_Miss;
267 }
268 }
269
272 HammerHit->unk_0C = 0;
273 HammerHit->unk_14 = 0;
274 }
275
276 playerStatus->flags &= ~PS_FLAG_HAMMER_CHECK;
277 if (HammerHit->timer < 3 && (playerStatus->flags & PS_FLAG_ENTERING_BATTLE)) {
278 // This is probably to stop Mario from triggering multiple battles at once by hammering while one is starting.
279 playerStatus->flags |= PS_FLAG_TIME_STOPPED;
280 } else if (HammerHit->timer < 2) {
281 HammerHit->timer++;
282 } else {
284 }
285}
@ PS_FLAG_TIME_STOPPED
Definition enums.h:3081
@ PS_FLAG_ENTERING_BATTLE
Definition enums.h:3061
@ PS_FLAG_NO_FLIPPING
Definition enums.h:3067
@ SOUND_HAMMER_SWING_3
Definition enums.h:1556
@ SOUND_HAMMER_SWING_1
Definition enums.h:1554
@ SOUND_HAMMER_SWING_2
Definition enums.h:1555
HammerHitData * HammerHit
Definition hammer.c:23
@ SUBSTATE_HAMMER_0
Definition hammer.c:7
void action_hammer_end_swing(void)
Definition hammer.c:287
HitID action_hammer_test_swing_collision(void)
Definition hammer.c:117

◆ action_update_launch()

void action_update_launch ( void )

Definition at line 118 of file misc.c.

118 {
119 PlayerStatus* playerStatus = &gPlayerStatus;
120
121 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
123 playerStatus->actionSubstate = 0;
124 playerStatus->curStateTime = 0;
125 playerStatus->timeInAir = 0;
126 playerStatus->peakJumpTime = 0;
127 playerStatus->curSpeed = 0.0f;
128 playerStatus->pitch = 0.0f;
129
130 if (playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS) {
131 return;
132 }
133 playerStatus->curStateTime = 5;
134 }
135
136 playerStatus->curStateTime--;
137 if (playerStatus->curStateTime == 0) {
139 }
140}

◆ action_update_pushing_block()

void action_update_pushing_block ( void )

Definition at line 182 of file misc.c.

182 {
183 PlayerStatus* playerStatus = &gPlayerStatus;
184
185 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
186 f32 angle;
187 f32 magnitude;
188
189 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
190 playerStatus->curSpeed = 0.0f;
191 playerStatus->unk_60 = 0;
192 playerStatus->curStateTime = 5;
193 player_input_to_move_vector(&angle, &magnitude);
194
195 if (((angle >= 45.0f) && (angle <= 135.0f)) || ((angle >= 225.0f) && (angle <= 315.0f))) {
196 suggest_player_anim_always_forward(ANIM_MarioW2_PushSide);
197 } else {
198 suggest_player_anim_allow_backward(ANIM_MarioW1_PushToward);
199 }
200 }
201
203
204 if (playerStatus->animFlags & PA_FLAG_ABORT_PUSHING_BLOCK) {
205 if (playerStatus->curStateTime != 0) {
206 playerStatus->curStateTime--;
207 if (playerStatus->curStateTime == 0) {
209 }
210 }
211 }
212}
@ PA_FLAG_ABORT_PUSHING_BLOCK
Definition enums.h:3117

◆ action_update_hit_fire()

void action_update_hit_fire ( void )

Definition at line 9 of file hit_fire.c.

9 {
10 PlayerStatus* playerStatus = &gPlayerStatus;
11 f32 dx, dy;
12 f32 speed;
13
14 static f32 ReturnAngle;
15
16 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
17 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
18
20 playerStatus->flags |= (PS_FLAG_HIT_FIRE | PS_FLAG_FLYING);
21
22 suggest_player_anim_always_forward(ANIM_Mario1_TouchedFire);
23
24 playerStatus->actionSubstate = SUBSTATE_FLYING;
25 playerStatus->gravityIntegrator[0] = 18.3473f;
26 playerStatus->gravityIntegrator[1] = -3.738f;
27 playerStatus->gravityIntegrator[2] = 0.8059f;
28 playerStatus->gravityIntegrator[3] = -0.0987f;
30 ReturnAngle = atan2(playerStatus->pos.x, playerStatus->pos.z, playerStatus->lastGoodPos.x, playerStatus->lastGoodPos.z);
31 playerStatus->curSpeed = get_xz_dist_to_player(playerStatus->lastGoodPos.x, playerStatus->lastGoodPos.z) / 18.0f;
32 subtract_hp(1);
35 }
36
37 sin_cos_rad(DEG_TO_RAD(ReturnAngle), &dx, &dy);
38 speed = playerStatus->curSpeed;
39
40 if (playerStatus->flags & PS_FLAG_ENTERING_BATTLE) {
41 speed *= 0.5;
42 }
43
44 playerStatus->pos.x += speed * dx;
45 playerStatus->pos.z -= speed * dy;
46
47 if (playerStatus->actionSubstate == SUBSTATE_FLYING) {
49 playerStatus->pos.y += playerStatus->gravityIntegrator[0];
50 if (playerStatus->gravityIntegrator[0] < 0.0f) {
51 playerStatus->actionSubstate = SUBSTATE_FALLING;
52 playerStatus->flags |= PS_FLAG_FALLING;
53 }
54 } else {
55 s32 colliderID;
56
57 playerStatus->pos.y = player_check_collision_below(player_fall_distance(), &colliderID);
58 if (colliderID > NO_COLLIDER) {
59 colliderID = get_collider_flags(colliderID); //TODO surfaceType
61 playerStatus->blinkTimer = 60;
62 playerStatus->hazardType = HAZARD_TYPE_NONE;
63 playerStatus->flags &= ~PS_FLAG_HIT_FIRE;
64 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
65 }
66 }
67}
#define atan2
@ HAZARD_TYPE_NONE
Definition enums.h:3499
@ GLOBAL_OVERRIDES_40
Definition enums.h:4325
void subtract_hp(s32 amt)
Definition inventory.c:2192
f32 get_xz_dist_to_player(f32, f32)
Definition 77480.c:960
void open_status_bar_slowly(void)
Definition inventory.c:1420
@ SUBSTATE_FALLING
Definition hit_fire.c:6
@ SUBSTATE_FLYING
Definition hit_fire.c:5
s32 gOverrideFlags
Definition main_loop.c:11

◆ action_update_knockback()

void action_update_knockback ( void )

Definition at line 9 of file knockback.c.

9 {
10 PlayerStatus* playerStatus = &gPlayerStatus;
11 f32 dx, dy;
12 f32 speed;
13
14 static f32 ReturnAngle;
15
16 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
17 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
18
19 suggest_player_anim_always_forward(ANIM_Mario1_Hurt);
20
21 playerStatus->flags |= PS_FLAG_FLYING;
22
23 playerStatus->actionSubstate = SUBSTATE_FLYING;
24 playerStatus->gravityIntegrator[0] = 18.3473f;
25 playerStatus->gravityIntegrator[1] = -3.738f;
26 playerStatus->gravityIntegrator[2] = 0.8059f;
27 playerStatus->gravityIntegrator[3] = -0.0987f;
28
30
31 ReturnAngle = atan2(playerStatus->pos.x, playerStatus->pos.z, playerStatus->lastGoodPos.x,
32 playerStatus->lastGoodPos.z);
33 playerStatus->curSpeed = get_xz_dist_to_player(playerStatus->lastGoodPos.x, playerStatus->lastGoodPos.z) / 18.0f;
34 }
35
36 sin_cos_rad(DEG_TO_RAD(ReturnAngle), &dx, &dy);
37
38 speed = playerStatus->curSpeed;
39
40 if (playerStatus->flags & PS_FLAG_ENTERING_BATTLE) {
41 speed *= 0.5f;
42 }
43
44 playerStatus->pos.x += speed * dx;
45 playerStatus->pos.z -= speed * dy;
46
47 if (playerStatus->actionSubstate == SUBSTATE_FLYING) {
49
50 playerStatus->pos.y += playerStatus->gravityIntegrator[0];
51
52 if (playerStatus->gravityIntegrator[0] < 0.0f) {
53 playerStatus->actionSubstate = SUBSTATE_FALLING;
54 playerStatus->flags |= PS_FLAG_FALLING;
55 }
56 } else {
57 s32 colliderID;
58
59 playerStatus->pos.y = player_check_collision_below(player_fall_distance(), &colliderID);
60
61 if (colliderID > NO_COLLIDER) {
62 colliderID = get_collider_flags(colliderID); //TODO surfaceType
64 }
65 }
66}
@ SUBSTATE_FALLING
Definition knockback.c:6
@ SUBSTATE_FLYING
Definition knockback.c:5

◆ action_update_hit_lava()

void action_update_hit_lava ( void )

Definition at line 19 of file hit_lava.c.

19 {
20 PlayerStatus* playerStatus = &gPlayerStatus;
21 f32 resetPosX, resetPosY, resetPosZ;
22 f32 returnRadians;
23 f32 dx, dy;
24 f32 componentSpeed;
25 s32 completeAxes; // number of axes along which the 'return motion' is complete
26
27 static f32 LaunchVelocity;
28 static f32 LaunchInterpPhase; // used to interp launch velocity
29 static f32 ReturnAngle;
30 static f32 InitialPosY;
31
32 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
33 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
34 playerStatus->flags |= (PS_FLAG_SCRIPTED_FALL | PS_FLAG_FLYING);
36 playerStatus->flags |= PS_FLAG_HIT_FIRE;
37 if (playerStatus->hazardType == HAZARD_TYPE_LAVA) {
39 playerStatus->curStateTime = 2;
40 } else {
41 playerStatus->actionSubstate = SUBSTATE_INIT;
42 }
43 InitialPosY = playerStatus->pos.y;
44 playerStatus->curSpeed = 0.0f;
45 LaunchVelocity = 0.0f;
46
48 LaunchInterpPhase = 90.0f;
49 subtract_hp(1);
53 }
54
55 switch (playerStatus->actionSubstate) {
57 if (--playerStatus->curStateTime == -1) {
58 playerStatus->actionSubstate = SUBSTATE_INIT;
59 }
60 break;
62 if (--playerStatus->curStateTime == -1) {
63 playerStatus->actionSubstate = SUBSTATE_INIT;
64 }
65 playerStatus->pos.y -= 4.0f;
66 break;
67 case SUBSTATE_INIT:
68 if (playerStatus->hazardType == HAZARD_TYPE_LAVA) {
69 fx_smoke_burst(0, playerStatus->pos.x, playerStatus->pos.y, playerStatus->pos.z, 1.0f, 40);
70 }
71 suggest_player_anim_always_forward(ANIM_MarioW2_TouchedLava);
72 playerStatus->gravityIntegrator[1] = 0.0f;
73 playerStatus->timeInAir = 0;
74 playerStatus->peakJumpTime = 0;
75 playerStatus->actionSubstate = SUBSTATE_LAUNCH;
76 playerStatus->curStateTime = 1;
77 playerStatus->gravityIntegrator[0] = 20.0f;
78 playerStatus->gravityIntegrator[2] = 250.0f;
79 playerStatus->gravityIntegrator[3] = InitialPosY;
80 playerStatus->jumpFromPos.x = playerStatus->pos.x;
81 playerStatus->jumpFromPos.z = playerStatus->pos.z;
82 playerStatus->jumpFromHeight = playerStatus->pos.y;
83 playerStatus->flags |= PS_FLAG_JUMPING;
84 break;
86 if (--playerStatus->curStateTime <= 0) {
87 playerStatus->actionSubstate++;
88 }
89 break;
90 case SUBSTATE_LAUNCH:
91 if (playerStatus->hazardType == HAZARD_TYPE_LAVA && (playerStatus->timeInAir % 2) == 0) {
92 fx_smoke_burst(0, playerStatus->pos.x, playerStatus->pos.y, playerStatus->pos.z, 0.7f, 18);
93 }
94 if (playerStatus->pos.y < playerStatus->gravityIntegrator[3] + playerStatus->gravityIntegrator[2]) {
95 sin_cos_rad(DEG_TO_RAD(LaunchInterpPhase), &dx, &dy);
96 LaunchVelocity = sin_rad(DEG_TO_RAD(LaunchInterpPhase)) * 16.0f;
97 if (LaunchVelocity < -1.0f) {
98 LaunchVelocity = -1.0f;
99 }
100 playerStatus->pos.y += LaunchVelocity;
101 LaunchInterpPhase += 3.0f;
102 if (LaunchInterpPhase > 180.0f) {
103 LaunchInterpPhase = 180.0f;
104 playerStatus->actionSubstate++;
105 }
106 } else {
107 playerStatus->pos.y = playerStatus->gravityIntegrator[3] + playerStatus->gravityIntegrator[2];
108 playerStatus->actionSubstate++;
109 }
110 break;
112 if (playerStatus->hazardType == HAZARD_TYPE_LAVA && (playerStatus->timeInAir % 2) == 0) {
113 fx_smoke_burst(0, playerStatus->pos.x, playerStatus->pos.y, playerStatus->pos.z, 0.7f, 18);
114 }
115 if (get_lava_reset_pos(&resetPosX, &resetPosY, &resetPosZ) == 0) {
116 resetPosX = playerStatus->pos.x;
117 resetPosZ = playerStatus->pos.z;
118 }
119 playerStatus->lastGoodPos.x = resetPosX;
120 playerStatus->lastGoodPos.z = resetPosZ;
121 playerStatus->jumpApexHeight = playerStatus->pos.y;
123 playerStatus->actionSubstate++;
124 break;
126 ReturnAngle = atan2(playerStatus->pos.x, playerStatus->pos.z, playerStatus->lastGoodPos.x, playerStatus->lastGoodPos.z);
127 playerStatus->curSpeed = get_xz_dist_to_player(playerStatus->lastGoodPos.x, playerStatus->lastGoodPos.z) / 18.0f;
128 playerStatus->actionSubstate++;
129 break;
131 ReturnAngle = atan2(playerStatus->pos.x, playerStatus->pos.z, playerStatus->lastGoodPos.x, playerStatus->lastGoodPos.z);
132 returnRadians = DEG_TO_RAD(ReturnAngle);
133 // update motion along x axis
134 componentSpeed = playerStatus->curSpeed * sin_rad(returnRadians);
135 playerStatus->pos.x += componentSpeed;
136 completeAxes = 0;
137 if (componentSpeed >= 0.0f) {
138 if (playerStatus->lastGoodPos.x <= playerStatus->pos.x) {
139 playerStatus->pos.x = playerStatus->lastGoodPos.x;
140 completeAxes++;
141 }
142 } else {
143 if (playerStatus->pos.x <= playerStatus->lastGoodPos.x) {
144 playerStatus->pos.x = playerStatus->lastGoodPos.x;
145 completeAxes++;
146 }
147 }
148 // update motion along z axis
149 componentSpeed = playerStatus->curSpeed * cos_rad(returnRadians);
150 playerStatus->pos.z -= componentSpeed;
151 if (componentSpeed >= 0.0f) {
152 if (playerStatus->pos.z <= playerStatus->lastGoodPos.z) {
153 playerStatus->pos.z = playerStatus->lastGoodPos.z;
154 completeAxes++;
155 }
156 } else {
157 if (playerStatus->lastGoodPos.z <= playerStatus->pos.z) {
158 playerStatus->pos.z = playerStatus->lastGoodPos.z;
159 completeAxes++;
160 }
161 }
162 // if both axes are done, continue to next substate
163 if (completeAxes == 2) {
164 playerStatus->actionSubstate++;
165 }
166 break;
167 case SUBSTATE_HOVER:
168 if (playerStatus->hazardType == HAZARD_TYPE_LAVA && (playerStatus->timeInAir % 2) == 0) {
169 fx_smoke_burst(0, playerStatus->pos.x, playerStatus->pos.y, playerStatus->pos.z, 0.7f, 18);
170 }
171 playerStatus->pos.y = player_check_collision_below(player_fall_distance(), &completeAxes);
172 if (completeAxes >= 0) {
174 start_rumble(256, 50);
176 gCameras[CAM_DEFAULT].moveFlags &= ~CAMERA_MOVE_NO_INTERP_Y;
178 suggest_player_anim_always_forward(ANIM_MarioW2_Thrown);
179 playerStatus->flags &= ~PS_FLAG_HIT_FIRE;
180 playerStatus->flags &= ~PS_FLAG_FLYING;
181 playerStatus->hazardType = HAZARD_TYPE_NONE;
182 playerStatus->gravityIntegrator[0] = 6.0f;
183 playerStatus->pos.y += 6.0f;
184 playerStatus->actionSubstate++;
185 }
186 break;
187 case SUBSTATE_BOUNCE:
188 playerStatus->gravityIntegrator[0] -= 1.0;
189 playerStatus->pos.y = player_check_collision_below(playerStatus->gravityIntegrator[0], &completeAxes);
190 if (completeAxes >= 0) {
191 playerStatus->curStateTime = 10;
192 playerStatus->actionSubstate++;
193 }
194 break;
196 if (--playerStatus->curStateTime <= 0) {
198 playerStatus->flags &= ~PS_FLAG_SCRIPTED_FALL;
199 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
200 }
201 break;
202 }
203 if (playerStatus->actionSubstate < SUBSTATE_BOUNCE) {
204 playerStatus->timeInAir++;
205 }
206}
@ CAM_SHAKE_DECAYING_VERTICAL
Definition enums.h:1809
@ SOUND_PLAYER_COLLAPSE
Definition enums.h:1312
@ SOUND_TOUCH_LAVA
Definition enums.h:723
@ CAMERA_MOVE_NO_INTERP_Y
Definition enums.h:4733
s32 get_lava_reset_pos(f32 *x, f32 *y, f32 *z)
Definition map_api.c:597
f32 cos_rad(f32 x)
Definition 43F0.c:717
void exec_ShakeCamX(s32 arg0, s32 arg1, s32 arg2, f32 arg3)
Definition cam_api.c:374
f32 sin_rad(f32 x)
Definition 43F0.c:713
@ SUBSTATE_END_LAUNCH
Definition hit_lava.c:9
@ SUBSTATE_HOVER
Definition hit_lava.c:12
@ SUBSTATE_DELAY_INIT
Definition hit_lava.c:16
@ SUBSTATE_INIT
Definition hit_lava.c:6
@ SUBSTATE_DELAY_INIT_SINK
Definition hit_lava.c:15
@ SUBSTATE_BOUNCE
Definition hit_lava.c:13
@ SUBSTATE_RETURN_INIT
Definition hit_lava.c:10
@ SUBSTATE_DELAY_DONE
Definition hit_lava.c:14
@ SUBSTATE_LAUNCH
Definition hit_lava.c:8
@ SUBSTATE_DELAY_LAUNCH
Definition hit_lava.c:7
@ SUBSTATE_RETURN_MOTION
Definition hit_lava.c:11

◆ action_update_parasol()

void action_update_parasol ( void )

Definition at line 73 of file sneaky_parasol.c.

73 {
74 PlayerStatus* playerStatus = &gPlayerStatus;
77 Npc* disguiseNpc;
78 f32 prevFacingAngle;
79 s32 reachedTangentAngle;
80 f32 angle;
81 f32 radius;
82
83 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
84 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
87
88 playerStatus->timeInAir = 0;
89 playerStatus->peakJumpTime = 0;
90 playerStatus->curSpeed = 0;
91 playerStatus->pitch = 0;
92
93 if (playerStatus->spriteFacingAngle >= 90 && playerStatus->spriteFacingAngle < 270) {
94 transformation->playerRotationRate = 2;
95 } else {
96 transformation->playerRotationRate = -2;
97 }
98
99 if (!(playerStatus->animFlags & PA_FLAG_INVISIBLE)) {
100 playerStatus->curStateTime = 20;
102 transformation->disguiseTime = 15;
103 transformation->npc = parasol_get_npc();
104 } else {
105 playerStatus->actionSubstate = SUBSTATE_REVERT_INIT;
106 playerStatus->curStateTime = 40;
107 transformation->reverted = 1;
108 transformation->revertTime = 12;
111 playerStatus->flags |= PS_FLAG_ROTATION_LOCKED;
113 }
114 }
115
116 switch (playerStatus->actionSubstate) {
118 if (playerStatus->flipYaw[CAM_DEFAULT] == 0) {
120 suggest_player_anim_allow_backward(ANIM_Peach2_UseParasol);
122 playerStatus->actionSubstate++; // SUBSTATE_USE_PARASOL
123 } else {
124 suggest_player_anim_allow_backward(ANIM_Peach2_CantFitParasol);
125 playerStatus->actionSubstate = SUBSTATE_BLOCKED;
126 playerStatus->curStateTime = 10;
127 transformation->disguiseTime = 0;
128 }
129 }
131 if (--playerStatus->curStateTime == 0) {
132 suggest_player_anim_allow_backward(ANIM_Peach2_PutAwayParasol);
133 playerStatus->actionSubstate = SUBSTATE_PUT_AWAY;
134 if (transformation->npc == NULL) {
135 playerStatus->actionSubstate = SUBSTATE_FAILED;
136 } else {
138 }
139 }
140 break;
142 if (playerStatus->animNotifyValue != 0) {
143 playerStatus->curStateTime = 12;
144 playerStatus->flags |= PS_FLAG_ROTATION_LOCKED;
145 playerStatus->actionSubstate++; // SUBSTATE_DISGUISE_BEGIN
147 }
148 break;
150 if (--playerStatus->curStateTime == 0) {
151 playerStatus->curStateTime = 10;
152 transformation->revertTime = 10;
153 playerStatus->actionSubstate++; // SUBSTATE_DISGUISE_WAIT_FOR_ANGLE
154 }
156 break;
158 prevFacingAngle = playerStatus->spriteFacingAngle;
160 playerStatus->targetYaw = clamp_angle((cam->curYaw - playerStatus->spriteFacingAngle) - 90);
161 if (playerStatus->curStateTime == 0) {
162 // wait for the sprite to rotate into a position where it's tangent to the camera
163 reachedTangentAngle = FALSE;
164 if (transformation->playerRotationRate > 0) {
165 if (prevFacingAngle < 270 && playerStatus->spriteFacingAngle >= 270) {
166 reachedTangentAngle = TRUE;
167 }
168 }
169 if (transformation->playerRotationRate < 0) {
170 if (prevFacingAngle > 270 && playerStatus->spriteFacingAngle <= 270) {
171 reachedTangentAngle = TRUE;
172 }
173 }
174 if (reachedTangentAngle) {
176 playerStatus->curStateTime = 2;
177 if (peach_make_disguise_npc(playerStatus->availableDisguiseType) != NULL) {
180 }
181 }
182 } else {
183 playerStatus->curStateTime--;
184 }
185 break;
187 playerStatus->animFlags |= PA_FLAG_INVISIBLE;
189 playerStatus->actionSubstate++; // SUBSTATE_DISGUISE_SPIN_DOWN
191 if (--playerStatus->curStateTime == 0) {
192 playerStatus->actionSubstate++; // SUBSTATE_DISGUISE_FINISH_SPIN
193 }
195 break;
197 if (transformation->playerRotationRate > 0.0f) {
198 transformation->playerYawOffset -= 2.35;
199 if (transformation->playerYawOffset <= 0) {
200 transformation->playerYawOffset = 0;
201 playerStatus->curStateTime = 10;
202 playerStatus->actionSubstate++; // SUBSTATE_DISGUISE_DONE
203 playerStatus->spriteFacingAngle = 180;
205 disguiseNpc->isFacingAway = TRUE;
206 disguiseNpc->yaw = clamp_angle((cam->curYaw - playerStatus->spriteFacingAngle) - 90);
207 disguiseNpc->yawCamOffset = disguiseNpc->yaw;
208 }
209 } else {
210 transformation->playerYawOffset += 2.35;
211 if (transformation->playerYawOffset >= 0) {
212 transformation->playerYawOffset = 0;
213 playerStatus->curStateTime = 10;
214 playerStatus->spriteFacingAngle = 0;
215 playerStatus->actionSubstate++; // SUBSTATE_DISGUISE_DONE
217 disguiseNpc->isFacingAway = FALSE;
218 disguiseNpc->yaw = clamp_angle((cam->curYaw - playerStatus->spriteFacingAngle) - 90);
219 disguiseNpc->yawCamOffset = disguiseNpc->yaw;
220 }
221 }
222 playerStatus->spriteFacingAngle = clamp_angle(playerStatus->spriteFacingAngle + transformation->playerYawOffset);
223 playerStatus->targetYaw = clamp_angle((cam->curYaw - playerStatus->spriteFacingAngle) - 90);
224 break;
226 if (--playerStatus->curStateTime == 0) {
229 disguiseNpc->flags &= ~NPC_FLAG_IGNORE_CAMERA_FOR_YAW;
230 playerStatus->flags &= ~PS_FLAG_ROTATION_LOCKED;
233 }
234 break;
236 if (--playerStatus->curStateTime == 0) {
237 playerStatus->actionSubstate++; // SUBSTATE_REVERT_WAIT_FOR_ANGLE
238 }
240 playerStatus->targetYaw = clamp_angle(cam->curYaw - playerStatus->spriteFacingAngle - 90);
241 break;
243 prevFacingAngle = playerStatus->spriteFacingAngle;
245 playerStatus->targetYaw = clamp_angle((cam->curYaw - playerStatus->spriteFacingAngle) - 90);
246 if (playerStatus->curStateTime == 0) {
247 // wait for the sprite to rotate into a position where it's tangent to the camera
248 reachedTangentAngle = FALSE;
249 if (transformation->playerRotationRate > 0) {
250 if (prevFacingAngle < 270 && playerStatus->spriteFacingAngle >= 270) {
251 reachedTangentAngle = TRUE;
252 }
253 }
254 if (transformation->playerRotationRate < 0) {
255 if (prevFacingAngle > 270 && playerStatus->spriteFacingAngle <= 270) {
256 reachedTangentAngle = TRUE;
257 }
258 }
259 if (reachedTangentAngle) {
260 playerStatus->curStateTime = 2;
261 playerStatus->actionSubstate++; // SUBSTATE_SPIN_DOWN
262 playerStatus->animFlags &= ~PA_FLAG_INVISIBLE;
263 gGameStatus.peachFlags &= ~PEACH_FLAG_DISGUISED;
264 playerStatus->peachDisguise = 0;
266 playerStatus->colliderHeight = 55;
267 playerStatus->colliderDiameter = 38;
268 }
269 } else {
270 playerStatus->curStateTime--;
271 }
272 break;
274 if (--playerStatus->curStateTime == 0) {
275 playerStatus->actionSubstate++; // SUBSTATE_FINISH_SPIN
276 }
278 break;
280 if (transformation->playerRotationRate > 0) {
281 transformation->playerYawOffset -= 2.35;
282 if (transformation->playerYawOffset <= 0) {
283 transformation->playerYawOffset = 0;
284 playerStatus->curStateTime = 10;
285 playerStatus->actionSubstate++; // SUBSTATE_REVERT_DONE
286 playerStatus->spriteFacingAngle = 180;
288 playerStatus->curYaw = clamp_angle((cam->curYaw - 180) - 90);
289 PrevPlayerCamRelativeYaw = playerStatus->curYaw;
290 }
291 } else {
292 transformation->playerYawOffset += 2.35;
293 if (transformation->playerYawOffset >= 0) {
294 transformation->playerYawOffset = 0;
295 playerStatus->curStateTime = 10;
296 playerStatus->spriteFacingAngle = 0;
297 playerStatus->actionSubstate++; // SUBSTATE_REVERT_DONE
299 playerStatus->curYaw = clamp_angle((cam->curYaw - 0) - 90);
300 PrevPlayerCamRelativeYaw = playerStatus->curYaw;
301 }
302 }
303 playerStatus->spriteFacingAngle = clamp_angle(playerStatus->spriteFacingAngle + transformation->playerYawOffset);
304 playerStatus->targetYaw = clamp_angle(cam->curYaw - playerStatus->spriteFacingAngle - 90);
305 break;
307 if (--playerStatus->curStateTime == 0) {
309 playerStatus->flags &= ~PS_FLAG_ROTATION_LOCKED;
312 }
313 break;
314 case SUBSTATE_ABORT:
317 break;
318 case SUBSTATE_FAILED:
319 if (playerStatus->animNotifyValue != 0) {
322 }
323 break;
324 case SUBSTATE_BLOCKED:
325 if (--playerStatus->curStateTime == 0) {
328 }
329 break;
330 }
331
332 if (transformation->disguiseTime > 0) {
333 if (--transformation->disguiseTime == 10) {
334 if (playerStatus->spriteFacingAngle >= 90 && playerStatus->spriteFacingAngle < 270) {
335 angle = DEG_TO_RAD(cam->curYaw - 270);
336 radius = 46;
337 } else {
338 angle = DEG_TO_RAD(cam->curYaw - 90);
339 radius = 30;
340 }
341 transformation->pos.x = playerStatus->pos.x + (radius * sin_rad(angle));
342 transformation->pos.z = playerStatus->pos.z - (radius * cos_rad(angle));
343 transformation->pos.y = playerStatus->pos.y - 20;
344 }
345 if (transformation->disguiseTime <= 10 && transformation->disguiseTime & 1) {
346 fx_sparkles(FX_SPARKLES_3,
347 transformation->pos.x - 8,
348 transformation->pos.y + 50,
349 transformation->pos.z,
350 2);
351
352 angle = DEG_TO_RAD((cam->curYaw + playerStatus->spriteFacingAngle) - 90);
353 transformation->pos.x += (10.0 * sin_rad(angle));
354 transformation->pos.z -= (10.0 * cos_rad(angle));
355 }
356 } else if (transformation->disguiseTime == 0) {
357 transformation->disguiseTime = -1;
358 if (transformation->npc != NULL) {
359 fx_pink_sparkles(playerStatus->availableDisguiseType - 1,
360 transformation->npc->pos.x,
361 transformation->npc->pos.y,
362 transformation->npc->pos.z,
363 1, transformation->npc->yawCamOffset);
364 }
365 }
366 if (transformation->revertTime != 0) {
367 if (transformation->revertTime <= 10) {
368 if (transformation->revertTime == 10) {
370 }
371 if ((transformation->revertTime & 3) == 0) {
372 fx_stars_shimmer(4,
373 playerStatus->pos.x,
374 playerStatus->pos.y,
375 playerStatus->pos.z,
376 50, 50, 40, 30);
377 }
378 }
379 transformation->revertTime--;
380 }
381}
s8 availableDisguiseType
set in main map scripts
#define mem_clear
@ FX_SPARKLES_3
Definition effects.h:237
@ PEACH_FLAG_DISGUISED
Definition enums.h:2489
@ PS_FLAG_ROTATION_LOCKED
Definition enums.h:3065
@ TIME_FREEZE_FULL
Definition enums.h:3466
@ TIME_FREEZE_NONE
Definition enums.h:3464
@ SOUND_KKJ_USE_SNEAKY_PARASOL
Definition enums.h:660
@ SOUND_SNEAKY_PARASOL_TRANSFORM
Definition enums.h:740
@ SOUND_SNEAKY_PARASOL_COPY
Definition enums.h:739
@ NPC_FLAG_IGNORE_CAMERA_FOR_YAW
Definition enums.h:3016
s32 disable_player_static_collisions(void)
Definition 77480.c:972
void peach_sync_disguise_npc(void)
Definition 7E9D0.c:555
void set_time_freeze_mode(s32)
Time freeze modes: 0: none 1: NPCs move, can't be interacted with 2: NPCs don't move,...
Definition main_loop.c:358
s32 enable_player_static_collisions(void)
Definition 77480.c:980
Npc * peach_make_disguise_npc(s32 peachDisguise)
Definition 7E9D0.c:573
void free_npc_by_index(s32 listIndex)
Definition npc.c:202
Npc * get_npc_by_index(s32 listIndex)
Definition npc.c:271
@ SUBSTATE_DISGUISE_INIT
@ SUBSTATE_DISGUISE_MAKE_NPC
@ SUBSTATE_USE_PARASOL
@ SUBSTATE_BLOCKED
@ SUBSTATE_DISGUISE_SPIN_DOWN
@ SUBSTATE_REVERT_WAIT_FOR_ANGLE
@ SUBSTATE_DISGUISE_BEGIN
@ SUBSTATE_DISGUISE_FINISH_SPIN
@ SUBSTATE_SPIN_DOWN
@ SUBSTATE_FINISH_SPIN
@ SUBSTATE_DISGUISE_DONE
@ SUBSTATE_REVERT_DONE
@ SUBSTATE_DISGUISE_WAIT_FOR_ANGLE
@ SUBSTATE_PUT_AWAY
@ SUBSTATE_REVERT_INIT
@ SUBSTATE_FAILED
@ SUBSTATE_ABORT
Npc * parasol_get_npc(void)
BSS TransformationData ParasolTransformation
s32 peach_disguise_check_overlaps(void)
Definition 7E9D0.c:614
void peach_force_disguise_action(s32)
Definition 7E9D0.c:514
void parasol_update_spin(void)
s32 flags
b16 isFacingAway
s16 yawCamOffset
Vec3f pos
GameStatus gGameStatus
Definition main_loop.c:21
s32 PrevPlayerDirection
Definition 7B440.c:7
s32 PeachDisguiseNpcIndex
Definition 7B440.c:4

◆ action_update_spin()

void action_update_spin ( void )

Definition at line 27 of file spin.c.

27 {
28 PlayerSpinState* playerSpinState = &gPlayerSpinState;
29 PlayerStatus* playerStatus = &gPlayerStatus;
30 f32 angle, magnitude, speedModifier;
31
32 s32 spinFlags, nonDizzyFlags;
33 s32 effectType;
34 AnimID anim;
35 s32 firstCall = FALSE;
36
37 // initialization
38 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
40 playerStatus->animFlags &= ~PA_FLAG_INTERRUPT_SPIN;
41 playerStatus->animFlags |= PA_FLAG_SPINNING;
42 playerStatus->flags |= PS_FLAG_SPINNING;
43 playerStatus->curStateTime = 0;
44 playerStatus->actionSubstate = SUBSTATE_SPIN_0;
45 playerSpinState->stopSoundTimer = 0;
46 playerSpinState->hasBufferedSpin = FALSE;
47 playerSpinState->spinDirectionMagnitude = 0.0f;
48 playerSpinState->spinDirection.x = 0.0f;
49 playerSpinState->spinDirection.y = 0.0f;
50 playerSpinState->hitWallTime = 0;
51 playerSpinState->bufferedStickAxis.x = 0;
52 playerSpinState->bufferedStickAxis.y = 0;
53 playerSpinState->spinSoundID = 0;
54 playerStatus->specialDecorationEffect = NULL;
55 playerSpinState->initialSpinTime = 25;
56 playerSpinState->fullSpeedSpinTime = 15;
57 playerSpinState->spinRate = 40.0f;
58 playerSpinState->speedScale = 2.0f;
59 playerSpinState->frictionScale = 0.5f;
60 playerSpinState->spinCountdown = playerSpinState->initialSpinTime;
61 spinFlags = SPIN_TYPE_DEFAULT;
62 firstCall = TRUE;
63
65 spinFlags |= SPIN_TYPE_ATTACK;
66 }
67
69 spinFlags |= SPIN_TYPE_DIZZY;
70 }
71
73 playerSpinState->initialSpinTime = 30;
74 playerSpinState->spinRate = 40.0f;
75 playerSpinState->fullSpeedSpinTime = 20;
76 playerSpinState->spinCountdown = playerSpinState->initialSpinTime;
77 playerSpinState->speedScale = 2.7f;
78 playerSpinState->frictionScale = 0.9f;
79 spinFlags |= SPIN_TYPE_SPEEDY;
80 }
81
82 effectType = -1;
83 anim = ANIM_Mario1_Spin;
84
85 if (spinFlags) {
86 if (spinFlags & SPIN_TYPE_ATTACK) {
87 effectType = 2;
88 anim = ANIM_Mario1_SpinAttack;
89 } else if (spinFlags & SPIN_TYPE_DIZZY) {
90 effectType = 4;
91 anim = ANIM_Mario1_Spin;
92 } else if (spinFlags & SPIN_TYPE_SPEEDY) {
93 effectType = 0;
94 anim = ANIM_Mario1_SpeedySpin;
95 }
96 }
97
98 playerSpinState->spinSoundID = SOUND_SPIN;
99 nonDizzyFlags = spinFlags & ~SPIN_TYPE_DIZZY;
100
101 if (nonDizzyFlags == SPIN_TYPE_ATTACK) {
102 playerSpinState->spinSoundID = SOUND_SPIN_ATTACK;
103 }
104 if (nonDizzyFlags == SPIN_TYPE_SPEEDY) {
105 playerSpinState->spinSoundID = SOUND_SPEEDY_SPIN;
106 }
107 if (nonDizzyFlags == (SPIN_TYPE_ATTACK | SPIN_TYPE_SPEEDY)) {
108 playerSpinState->spinSoundID = SOUND_SPEEDY_SPIN_ATTACK;
109 }
110
113
114 if ((clamp_angle(playerStatus->targetYaw - gCameras[gCurrentCameraID].curYaw) <= 180.0f)) {
115 playerStatus->spinRate = playerSpinState->spinRate;
116 } else {
117 effectType++;
118 playerStatus->spinRate = -playerSpinState->spinRate;
119 }
120 if (spinFlags != 0) {
121 playerStatus->specialDecorationEffect = fx_effect_46(effectType, playerStatus, 1.0f, 1000);
122 }
123
125 player_input_to_move_vector(&angle, &magnitude);
126 playerStatus->targetYaw = angle;
127 playerSpinState->inputMagnitude = magnitude;
128 }
129
130 // update saved position and rotation values for motion blur effect
134 }
142 }
143
144 // check for spin cancel
145 if (!firstCall && (check_input_hammer() || check_input_jump())) {
146 playerStatus->animFlags &= ~PA_FLAG_SPINNING;
147 playerStatus->flags &= ~PS_FLAG_SPINNING;
148 sfx_stop_sound(playerSpinState->spinSoundID);
149 player_input_to_move_vector(&angle, &magnitude);
150 playerStatus->targetYaw = angle;
151 return;
152 }
153
154 // check for buffered next spin
155 if (playerSpinState->spinCountdown < 11 && playerStatus->pressedButtons & BUTTON_Z) {
156 playerSpinState->hasBufferedSpin = TRUE;
157 playerSpinState->prevActionState = playerStatus->prevActionState;
158 playerSpinState->bufferedStickAxis.x = playerStatus->stickAxis[0];
159 playerSpinState->bufferedStickAxis.y = playerStatus->stickAxis[1];
160 }
161
162 // check for action finished
163 if (playerStatus->actionSubstate >= SUBSTATE_SPIN_2) {
164 playerSpinState->spinDirectionMagnitude -= 1.0f;
165 if (playerSpinState->spinDirectionMagnitude < 0.0f) {
166 playerSpinState->spinDirectionMagnitude = 0.0f;
167 }
168
169 angle = clamp_angle(playerStatus->targetYaw - gCameras[gCurrentCameraID].curYaw);
170 playerSpinState->spinDirection.x = sin_rad(DEG_TO_RAD(angle)) * playerSpinState->spinDirectionMagnitude;
171 playerSpinState->spinDirection.y = -cos_rad(DEG_TO_RAD(angle)) * playerSpinState->spinDirectionMagnitude;
172 playerStatus->curStateTime--;
173 if (playerStatus->curStateTime == 0) {
174 playerSpinState->stopSoundTimer = 4;
176 playerStatus->flags &= ~PS_FLAG_SPINNING;
177 playerStatus->animFlags &= ~PA_FLAG_SPINNING;
178 sfx_stop_sound(playerSpinState->spinSoundID);
179 }
180 playerStatus->curSpeed = 0.0f;
181 return;
182 }
183
184 if (playerStatus->actionSubstate == SUBSTATE_SPIN_0) {
185 if (playerStatus->animFlags & PA_FLAG_INTERRUPT_SPIN) {
186 playerStatus->actionSubstate = SUBSTATE_SPIN_1;
188 playerSpinState->hitWallTime++;
189 if (playerSpinState->hitWallTime >= 10) {
190 playerStatus->actionSubstate = SUBSTATE_SPIN_1;
191 }
192 }
193 }
194
195 if (!(playerStatus->curStateTime > playerSpinState->fullSpeedSpinTime)) {
196 speedModifier = (playerSpinState->inputMagnitude) ? playerSpinState->speedScale : 0.0f;
197 playerSpinState->spinDirectionMagnitude = playerSpinState->spinDirectionMagnitude + 0.9;
198
199 if (playerSpinState->spinDirectionMagnitude > 9.0f) {
200 playerSpinState->spinDirectionMagnitude = 9.0f;
201 }
202
203 angle = clamp_angle(playerStatus->targetYaw - gCameras[gCurrentCameraID].curYaw);
204 playerSpinState->spinDirection.x = sin_rad(DEG_TO_RAD(angle)) * playerSpinState->spinDirectionMagnitude;
205 playerSpinState->spinDirection.y = -cos_rad(DEG_TO_RAD(angle)) * playerSpinState->spinDirectionMagnitude;
206 } else {
207 speedModifier = playerSpinState->speedScale - (playerStatus->curStateTime - playerSpinState->fullSpeedSpinTime - 1) * playerSpinState->frictionScale;
208 if (speedModifier < 0.1) {
209 speedModifier = 0.1f;
210 }
211
212 if (playerSpinState->inputMagnitude == 0.0f) {
213 speedModifier = 0.0f;
214 }
215
216 playerSpinState->spinDirectionMagnitude -= 1.0f;
217 if (playerSpinState->spinDirectionMagnitude < 0.0f) {
218 playerSpinState->spinDirectionMagnitude = 0.0f;
219 }
220 }
221
222 playerStatus->curStateTime++;
223
224 switch (playerStatus->prevActionState) {
226 player_input_to_move_vector(&angle, &magnitude);
228 if (check_input_jump()) {
229 if (magnitude != 0.0f || playerStatus->targetYaw != angle) {
230 playerStatus->targetYaw = angle;
231 }
232 }
233 playerStatus->curSpeed = (magnitude != 0.0f) ? playerStatus->runSpeed * speedModifier : 0.0f;
234 break;
236 case ACTION_STATE_RUN:
237 playerStatus->curSpeed = playerStatus->runSpeed * speedModifier;
238 break;
239 }
240 if (playerStatus->actionSubstate == SUBSTATE_SPIN_0) {
241 playerSpinState->spinCountdown--;
242 if (playerSpinState->spinCountdown > 0) {
243 if (playerStatus->curStateTime >= 2) {
244 playerStatus->spriteFacingAngle = clamp_angle(playerStatus->spriteFacingAngle + playerStatus->spinRate);
245 }
246 return;
247 } else {
248 playerStatus->actionSubstate = SUBSTATE_SPIN_1;
249 }
250 }
251
252 if (playerStatus->actionSubstate == SUBSTATE_SPIN_1) {
253 angle = playerStatus->spriteFacingAngle;
254 playerStatus->spriteFacingAngle = angle + playerStatus->spinRate;
255
256 if (playerSpinState->hasBufferedSpin) {
257 playerStatus->curStateTime = 2;
258 playerStatus->actionSubstate = SUBSTATE_SPIN_2;
259 playerStatus->flags &= ~PS_FLAG_SPINNING;
260 suggest_player_anim_allow_backward(ANIM_Mario1_Idle);
261 } else if (angle < playerStatus->spriteFacingAngle) {
262 if (playerStatus->spriteFacingAngle >= 180.0f && angle < 180.0f) {
263 playerStatus->spriteFacingAngle = 180.0f;
264 playerStatus->curStateTime = 2;
265 playerStatus->actionSubstate = SUBSTATE_SPIN_2;
266 playerStatus->flags &= ~PS_FLAG_SPINNING;
267 suggest_player_anim_allow_backward(ANIM_Mario1_Idle);
268 }
269 } else if (playerStatus->spriteFacingAngle <= 0.0f && angle < 90.0f) {
270 playerStatus->spriteFacingAngle = 0.0f;
271 playerStatus->curStateTime = 2;
272 playerStatus->actionSubstate = SUBSTATE_SPIN_2;
273 playerStatus->flags &= ~PS_FLAG_SPINNING;
274 suggest_player_anim_allow_backward(ANIM_Mario1_Idle);
275 }
276 playerStatus->spriteFacingAngle = clamp_angle(playerStatus->spriteFacingAngle);
277 }
278}
struct EffectInstance * specialDecorationEffect
@ BUTTON_Z
Definition enums.h:2788
@ PA_FLAG_INTERRUPT_SPIN
Definition enums.h:3110
@ ABILITY_SPIN_ATTACK
Definition enums.h:476
@ ABILITY_DIZZY_ATTACK
Definition enums.h:481
@ ABILITY_SPEEDY_SPIN
Definition enums.h:475
@ SOUND_SPEEDY_SPIN_ATTACK
Definition enums.h:1553
@ SOUND_SPEEDY_SPIN
Definition enums.h:1551
@ SOUND_SPIN_ATTACK
Definition enums.h:1552
@ SOUND_SPIN
Definition enums.h:1550
void sfx_stop_sound(s32 soundID)
Definition sfx.c:507
#define ARRAY_COUNT(arr)
Definition macros.h:40
s32 gSpinHistoryPosY[5]
Definition 7E9D0.c:27
@ SPIN_TYPE_SPEEDY
Definition spin.c:22
@ SPIN_TYPE_DEFAULT
Definition spin.c:21
@ SPIN_TYPE_ATTACK
Definition spin.c:24
@ SPIN_TYPE_DIZZY
Definition spin.c:23
s32 gSpinHistoryPosX[5]
Definition 7E9D0.c:26
s32 gSpinHistoryBufferPos
Definition 7E9D0.c:24
s16 gSpinHistoryPosAngle[5]
Definition 7E9D0.c:29
@ SUBSTATE_SPIN_0
Definition spin.c:14
@ SUBSTATE_SPIN_1
Definition spin.c:15
@ SUBSTATE_SPIN_2
Definition spin.c:16
s32 gSpinHistoryPosZ[5]
Definition 7E9D0.c:28
void phys_clear_spin_history(void)
Definition 7E9D0.c:71
PlayerSpinState gPlayerSpinState
Definition 7B440.c:11

◆ action_update_step_up_peach()

void action_update_step_up_peach ( void )

Definition at line 85 of file step_up.c.

85 {
86 PlayerStatus* playerStatus = &gPlayerStatus;
87
88 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
89 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
90 suggest_player_anim_allow_backward(ANIM_Peach1_StepUp);
91 playerStatus->curStateTime = 8;
92 }
93
94 if (playerStatus->curStateTime != 0) {
95 playerStatus->curStateTime--;
96#if !VERSION_JP
97 if (playerStatus->curStateTime == 4) {
99 }
100#endif
101 } else {
102 if (!(playerStatus->flags & PS_FLAG_CUTSCENE_MOVEMENT)) {
104 } else if (playerStatus->curSpeed >= playerStatus->runSpeed) {
106 } else {
108 }
109 }
110}

◆ action_update_ride()

void action_update_ride ( void )

Definition at line 9 of file misc.c.

9 {
10 PartnerStatus* partnerStatus = &gPartnerStatus;
11 PlayerStatus* playerStatus = &gPlayerStatus;
12
13 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
15 playerStatus->actionSubstate = 0;
16 playerStatus->curStateTime = 0;
17 playerStatus->timeInAir = 0;
18 playerStatus->peakJumpTime = 0;
19 playerStatus->curSpeed = 0.0f;
20 playerStatus->pitch = 0.0f;
21 }
22
23 if (playerStatus->animFlags & PA_FLAG_RIDING_PARTNER) {
24 if (partnerStatus->actingPartner == PARTNER_LAKILESTER) {
26 } else if (partnerStatus->actingPartner == PARTNER_SUSHIE) {
28 }
29 }
30}
@ PA_FLAG_RIDING_PARTNER
Definition enums.h:3116
@ PARTNER_LAKILESTER
Definition enums.h:2893
@ PARTNER_SUSHIE
Definition enums.h:2892
void world_lakilester_sync_player_position(void)
void world_sushie_sync_player_position(void)
PartnerStatus gPartnerStatus
Definition partners.c:42

◆ action_update_step_up()

void action_update_step_up ( void )

Definition at line 29 of file step_up.c.

29 {
30 PlayerStatus* playerStatus = &gPlayerStatus;
31 HitID colliderID;
32 f32 cosTheta;
33 f32 sinTheta;
34
35 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
36 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
38 if (playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS) {
40 } else if (playerStatus->animFlags & PA_FLAG_USING_WATT) {
41 suggest_player_anim_allow_backward(ANIM_MarioW1_CarryWalk);
42 } else {
43 suggest_player_anim_allow_backward(ANIM_Mario1_Walk);
44 }
45 playerStatus->actionSubstate = 0;
46 playerStatus->timeInAir = 0;
47 playerStatus->peakJumpTime = 0;
48 playerStatus->gravityIntegrator[0] = 17.7566f;
49 playerStatus->gravityIntegrator[1] = -11.3862f;
50 playerStatus->gravityIntegrator[2] = 3.5f;
51 playerStatus->gravityIntegrator[3] = -0.75f;
52 }
53
55 sin_cos_rad(DEG_TO_RAD(playerStatus->targetYaw), &sinTheta, &cosTheta);
56 colliderID = NO_COLLIDER;
57 playerStatus->pos.x += sinTheta * 3.0f;
58 playerStatus->pos.z -= cosTheta * 3.0f;
59
60 if (playerStatus->gravityIntegrator[0] < 0.0f) {
61 playerStatus->pos.y = player_check_collision_below(playerStatus->gravityIntegrator[0], &colliderID);
62 } else {
63 playerStatus->pos.y += playerStatus->gravityIntegrator[0];
64 }
65
66 if (colliderID > NO_COLLIDER) {
67 if (playerStatus->prevActionState != ACTION_STATE_SPIN) {
68 set_action_state(playerStatus->prevActionState);
69 } else {
71 }
72 }
73}
s32 HitID
@ ACTION_STATE_SPIN
Definition enums.h:2454
void action_update_step_up_set_peach_anim(void)
Definition step_up.c:75

◆ action_update_first_strike()

void action_update_first_strike ( void )

Definition at line 142 of file misc.c.

142 {
143 PlayerStatus* playerStatus = &gPlayerStatus;
144
145 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
147 playerStatus->actionSubstate = 0;
148 playerStatus->timeInAir = 0;
149 playerStatus->peakJumpTime = 0;
150 playerStatus->curSpeed = 0.0f;
151 playerStatus->pitch = 0.0f;
152 suggest_player_anim_always_forward(ANIM_Mario1_Hurt);
153 playerStatus->curStateTime = 30;
154 }
155
156 if (playerStatus->curStateTime != 0) {
157 playerStatus->curStateTime--;
158 } else if (gGameStatusPtr->context == CONTEXT_WORLD) {
160 }
161}
@ CONTEXT_WORLD
Definition enums.h:3529
GameStatus * gGameStatusPtr
Definition main_loop.c:32

◆ action_update_raise_arms()

void action_update_raise_arms ( void )

Definition at line 163 of file misc.c.

163 {
164 PlayerStatus* playerStatus = &gPlayerStatus;
165
166 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
167 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
168 playerStatus->flags |= PS_FLAG_ARMS_RAISED;
169 playerStatus->curStateTime = 0;
170 playerStatus->actionSubstate = 0;
171 playerStatus->curSpeed = 0.0f;
172 playerStatus->pitch = 0.0f;
173 suggest_player_anim_always_forward(ANIM_Mario1_UsePower);
174 }
175
176 if (!(playerStatus->animFlags & PA_FLAG_RAISED_ARMS)) {
178 playerStatus->flags &= ~PS_FLAG_ARMS_RAISED;
179 }
180}

◆ action_update_use_spinning_flower()

void action_update_use_spinning_flower ( void )

Definition at line 38 of file use_spinning_flower.c.

38 {
39 PlayerStatus* playerStatus = &gPlayerStatus;
40 Entity* entityByIndex;
41 s32* TempPointer;
42 s32 entityID;
43 f32 inputMagnitude;
44 f32 inputAngle;
45 f32 dz;
46 f32 dx;
47 f32 ascentVelocity;
48 f32 distToCenter;
49 s8 switchCondition;
50
51 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
52 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
55 playerStatus->actionSubstate = SUBSTATE_ATTRACT;
56 playerStatus->curStateTime = 0;
57 D_802B6EE4 = 0.0f;
58 D_802B6EE8 = 0.0f;
59 D_802B6EF4 = playerStatus->pos.y;
60 D_802B6EDC = 3.0f;
63 playerStatus->flags |= PS_FLAG_ROTATION_LOCKED;
64 entityID = gCollisionStatus.curFloor;
65#if VERSION_JP
67#endif
68
69 TempPointer = &SpinningFlower_EntityIndex;
70 if (entityID >= 0){
71 if (entityID & COLLISION_WITH_ENTITY_BIT) {
72 SpinningFlower_EntityIndex = entityID & 0x3FF;
73 } else {
75 }
76 } else {
78 }
79 if (!(playerStatus->animFlags & (PA_FLAG_USING_WATT | PA_FLAG_WATT_IN_HANDS))) {
80 suggest_player_anim_allow_backward(ANIM_Mario1_Flail);
81 }
82 }
83
84 switch (playerStatus->actionSubstate) {
87 D_802B6EE4 += 1.0f;
88 if (D_802B6EE4 >= 20.0f) {
89 D_802B6EE4 = 20.0f;
90 }
91 playerStatus->spriteFacingAngle = clamp_angle(playerStatus->spriteFacingAngle + D_802B6EE4);
92 if (playerStatus->curStateTime < 10) {
93 playerStatus->curStateTime++;
94 D_802B6EF4++;
95 }
96 D_802B6EE8 += 8.0f;
97 playerStatus->pos.y = D_802B6EF4 + sin_rad(DEG_TO_RAD(clamp_angle(D_802B6EE8))) * 4.0f;
100 distToCenter = dist2D(entityByIndex->pos.x, entityByIndex->pos.z, playerStatus->pos.x, playerStatus->pos.z);
101 SpinningFlower_AngleToCenter = atan2(entityByIndex->pos.x, entityByIndex->pos.z, playerStatus->pos.x, playerStatus->pos.z);
102 if (distToCenter > 4.0f) {
103 distToCenter--;
104 }
106 playerStatus->pos.x = entityByIndex->pos.x + (dx * distToCenter);
107 playerStatus->pos.z = entityByIndex->pos.z - (dz * distToCenter);
109 D_802B6ED4 = dx * D_802B6EDC;
110 D_802B6ED8 = -dz * D_802B6EDC;
111 }
112 game_input_to_move_vector(&inputAngle, &inputMagnitude);
113 if (inputMagnitude != 0.0f) {
114 sin_cos_rad(DEG_TO_RAD(inputAngle), &dx, &dz);
115 inputMagnitude *= 0.03125f;
116 if (inputMagnitude < 0.1) {
117 inputMagnitude = 0.1f;
118 }
119 playerStatus->pos.x += dx * inputMagnitude;
120 playerStatus->pos.z -= dz * inputMagnitude;
121 }
122 gCameras[CAM_DEFAULT].targetPos.x = playerStatus->pos.x;
123 gCameras[CAM_DEFAULT].targetPos.y = playerStatus->pos.y;
124 gCameras[CAM_DEFAULT].targetPos.z = playerStatus->pos.z;
125 entityID = get_entity_below_spinning_flower();
126 if (entityID < 0 || !(entityID & COLLISION_WITH_ENTITY_BIT)) {
127 playerStatus->curStateTime = 20;
128 D_802B6EE8 = 0.0f;
129 D_802B6EF4 = playerStatus->pos.y;
130 playerStatus->actionSubstate++;
131 D_802B6EF0 = 1.6f;
132 playerStatus->flags |= PS_FLAG_SCRIPTED_FALL;
133 }
135 !(playerStatus->animFlags & (PA_FLAG_USING_WATT | PA_FLAG_WATT_IN_HANDS))) {
136 suggest_player_anim_always_forward(ANIM_Mario1_Jump);
137 playerStatus->actionSubstate = SUBSTATE_SPIN_UP;
138 playerStatus->curStateTime = 30;
139 D_802B6EE0 = 0.0f;
142 }
143 break;
144 case SUBSTATE_EJECT:
146 if (--D_802B6EE4 < 0.0f) {
147 D_802B6EE4 = 0.0f;
148 playerStatus->flags &= ~PS_FLAG_ROTATION_LOCKED;
149 }
150 playerStatus->spriteFacingAngle = clamp_angle(playerStatus->spriteFacingAngle + D_802B6EE4);
152 D_802B6EDC += 0.2;
153 D_802B6EF0 -= 0.72;
154 D_802B6ED4 = dx * D_802B6EDC;
155 D_802B6ED8 = -dz * D_802B6EDC;
156 playerStatus->pos.x += D_802B6ED4;
157 playerStatus->pos.z += D_802B6ED8;
159 playerStatus->pos.y = player_check_collision_below(D_802B6EF0, &entityID);
160 gCameras[CAM_DEFAULT].targetPos.x = playerStatus->pos.x;
161 gCameras[CAM_DEFAULT].targetPos.y = playerStatus->pos.y;
162 gCameras[CAM_DEFAULT].targetPos.z = playerStatus->pos.z;
163 if (entityID >= 0) {
164 playerStatus->flags &= ~PS_FLAG_ROTATION_LOCKED;
169 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
170 return;
171 }
172 }
173
174 switch (playerStatus->actionSubstate) {
175 case SUBSTATE_SPIN_UP:
178 distToCenter = dist2D(entityByIndex->pos.x, entityByIndex->pos.z, playerStatus->pos.x, playerStatus->pos.z);
179 SpinningFlower_AngleToCenter = atan2(entityByIndex->pos.x, entityByIndex->pos.z, playerStatus->pos.x, playerStatus->pos.z);
180 if (distToCenter > 4.0f) {
181 distToCenter -= 1.0f;
182 }
184 playerStatus->pos.x = entityByIndex->pos.x + (dx * distToCenter);
185 playerStatus->pos.z = entityByIndex->pos.z - (dz * distToCenter);
187 D_802B6ED4 = dx * D_802B6EDC;
188 D_802B6ED8 = -dz * D_802B6EDC;
189 }
190 D_802B6EE8 += 8.0f;
191
192 playerStatus->pos.y = D_802B6EF4 + sin_rad(DEG_TO_RAD(clamp_angle(D_802B6EE8))) * 4.0f;
193 gCameras[CAM_DEFAULT].targetPos.z = playerStatus->pos.z;
194 gCameras[CAM_DEFAULT].targetPos.x = playerStatus->pos.x;
195 gCameras[CAM_DEFAULT].targetPos.y = playerStatus->pos.y;
196 if (playerStatus->curStateTime != 0) {
197 playerStatus->curStateTime--;
198 D_802B6EE4 += 2.0f;
199 if (D_802B6EE4 >= 45.0f) {
200 D_802B6EE4 = 45.0f;
201 }
202 playerStatus->spriteFacingAngle = clamp_angle(playerStatus->spriteFacingAngle + D_802B6EE4);
203 break;
204 }
205 playerStatus->actionSubstate++; // SUBSTATE_ASCEND_A
206 playerStatus->curStateTime = 30;
208 break;
210 D_802B6EE4 += 2.0f;
211 if (D_802B6EE4 >= 45.0f) {
212 D_802B6EE4 = 45.0f;
213 }
214 playerStatus->spriteFacingAngle = clamp_angle(playerStatus->spriteFacingAngle + D_802B6EE4);
215 D_802B6EE0 += 2.0f;
216 if (D_802B6EE0 > 45.0f) {
217 D_802B6EE0 = 45.0f;
218 }
219
220 ascentVelocity = sin_rad(DEG_TO_RAD(D_802B6EE0)) * 4.0f;
221 playerStatus->pos.y += ascentVelocity;
222 gCameras[CAM_DEFAULT].targetPos.x = playerStatus->pos.x;
223 gCameras[CAM_DEFAULT].targetPos.y = playerStatus->pos.y;
224 gCameras[CAM_DEFAULT].targetPos.z = playerStatus->pos.z;
225 distToCenter = fabsf(dist2D(FlowerGoalPosition.x, FlowerGoalPosition.z, playerStatus->pos.x, playerStatus->pos.z));
226 if (distToCenter > 40.0f) {
227 if (FlowerGoalPosition.y + 30 < playerStatus->pos.y) {
228 playerStatus->actionSubstate++; // SUBSTATE_ASCEND_B
229 inputAngle = atan2(playerStatus->pos.x, playerStatus->pos.z, FlowerGoalPosition.x, FlowerGoalPosition.z);
230 sin_cos_rad(DEG_TO_RAD(inputAngle), &dx, &dz);
231 playerStatus->curStateTime = 64;
232 SpinningFlower_AngleToCenter = inputAngle;
233 D_802B6ED4 = (dx * distToCenter) * 0.015625;
234 D_802B6ED8 = (-dz * distToCenter) * 0.015625;
235 }
236 break;
237 }
238 if (playerStatus->curStateTime == 0) {
239 playerStatus->actionSubstate = SUBSTATE_BOOST;
240 playerStatus->curStateTime = 20;
241 } else {
242 playerStatus->curStateTime--;
243 }
244 break;
246 playerStatus->spriteFacingAngle = clamp_angle(playerStatus->spriteFacingAngle + D_802B6EE4);
247 if (playerStatus->curStateTime != 0) {
248 playerStatus->curStateTime--;
249 if (D_802B6EE0-- < 0.0f) {
250 D_802B6EE0 = 0.0f;
251 }
252 ascentVelocity = 2.0f * sin_rad(DEG_TO_RAD(D_802B6EE0));
253 playerStatus->pos.x += D_802B6ED4;
254 playerStatus->pos.y += ascentVelocity;
255 playerStatus->pos.z += D_802B6ED8;
256 } else {
257 playerStatus->actionSubstate = SUBSTATE_FINISH;
258 }
259 gCameras[CAM_DEFAULT].targetPos.x = playerStatus->pos.x;
260 gCameras[CAM_DEFAULT].targetPos.y = playerStatus->pos.y;
261 gCameras[CAM_DEFAULT].targetPos.z = playerStatus->pos.z;
262 break;
263 case SUBSTATE_BOOST:
264 D_802B6EE4 += 1.0f;
265 if (D_802B6EE4 >= 45.0f) {
266 D_802B6EE4 = 45.0f;
267 }
268 playerStatus->spriteFacingAngle = clamp_angle(playerStatus->spriteFacingAngle + D_802B6EE4);
269 D_802B6EE0 += 2.0f;
270 if (D_802B6EE0 > 45.0f) {
271 D_802B6EE0 = 45.0f;
272 }
273 ascentVelocity = sin_rad(DEG_TO_RAD(D_802B6EE0)) * 3.0f;
274 playerStatus->pos.y += ascentVelocity;
275 if (playerStatus->curStateTime != 0) {
276 playerStatus->curStateTime--;
277 break;
278 }
279 case SUBSTATE_FINISH:
282 playerStatus->flags &= ~PS_FLAG_ROTATION_LOCKED;
283 playerStatus->flags |= PS_FLAG_SCRIPTED_FALL;
286 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
287 break;
288 }
289}
u32 pressedButtons[4]
void start_falling(void)
Definition 7E9D0.c:293
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
void game_input_to_move_vector(f32 *x, f32 *y)
Definition 7B440.c:162
void enable_partner_ai(void)
Definition partners.c:2390
void exec_entity_commandlist(Entity *entity)
Definition entity.c:313
void collision_lava_reset_check_additional_overlaps(void)
Definition 7BB60.c:990
void func_800EF300(void)
Definition partners.c:2382
Vec3f targetPos
@ SUBSTATE_EJECT
@ SUBSTATE_ATTRACT
@ SUBSTATE_ASCEND_A
@ SUBSTATE_ASCEND_B
@ SUBSTATE_BOOST
@ SUBSTATE_FINISH
@ SUBSTATE_SPIN_UP
Vec3s FlowerGoalPosition
Definition Plants1.c:24
BSS f32 D_802B6EE8
BSS f32 SpinningFlower_AngleToCenter
BSS f32 D_802B6ED8
BSS f32 D_802B6EE0
BSS s32 SpinningFlower_EntityIndex
BSS f32 D_802B6EE4
BSS f32 D_802B6EF0
BSS f32 D_802B6EDC
BSS f32 D_802B6ED4
BSS f32 D_802B6EF4

◆ action_update_use_munchlesia()

void action_update_use_munchlesia ( void )

Definition at line 18 of file use_munchlesia.c.

18 {
19 PlayerStatus* playerStatus = &gPlayerStatus;
20 s32 colliderID;
21 f32 hitPosY;
22
23 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
24 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
25 playerStatus->actionSubstate = SUBSTATE_INIT;
29 }
30
31 switch (playerStatus->actionSubstate) {
32 case SUBSTATE_INIT:
33 suggest_player_anim_allow_backward(ANIM_Mario1_FallBack);
34 D_802B62E0 = 32;
39 playerStatus->actionSubstate++; // SUBSTATE_EJECT
40 Munchlesia_LaunchYaw = playerStatus->targetYaw;
41 break;
42 case SUBSTATE_EJECT:
43 playerStatus->pos.y += Munchlesia_LaunchVelocity;
46 gCameras[CAM_DEFAULT].targetPos.x = playerStatus->pos.x;
47 gCameras[CAM_DEFAULT].targetPos.y = playerStatus->pos.y;
48 gCameras[CAM_DEFAULT].targetPos.z = playerStatus->pos.z;
49 if (Munchlesia_LaunchVelocity <= 0.0f) {
50 playerStatus->actionSubstate++; // SUBSTATE_FALL
51 }
52 break;
53 case SUBSTATE_FALL:
54 playerStatus->pos.y += Munchlesia_LaunchVelocity;
57 gCameras[CAM_DEFAULT].targetPos.x = playerStatus->pos.x;
58 gCameras[CAM_DEFAULT].targetPos.y = playerStatus->pos.y;
59 gCameras[CAM_DEFAULT].targetPos.z = playerStatus->pos.z;
61 if (colliderID > NO_COLLIDER) {
63 suggest_player_anim_always_forward(ANIM_MarioW2_Collapse);
64 playerStatus->pos.y = hitPosY;
65 D_802B62E0 = 10;
66 playerStatus->actionSubstate++; // SUBSTATE_CRASH
67 }
68 break;
69 case SUBSTATE_CRASH:
70 if (playerStatus->animNotifyValue != 0) {
71 suggest_player_anim_always_forward(ANIM_Mario1_GetUp);
72 playerStatus->actionSubstate = SUBSTATE_GET_UP;
73 playerStatus->curStateTime = 15;
74 break;
75 }
76 break;
77 case SUBSTATE_GET_UP:
78 if (playerStatus->curStateTime != 0) {
79 playerStatus->curStateTime--;
80 break;
81 }
85 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
86 break;
87 }
88}
void add_vec2D_polar(f32 *x, f32 *y, f32 r, f32 theta)
Definition 43F0.c:685
BSS f32 Munchlesia_LaunchAccel
@ SUBSTATE_FALL
@ SUBSTATE_EJECT
@ SUBSTATE_CRASH
@ SUBSTATE_INIT
@ SUBSTATE_GET_UP
BSS f32 Munchlesia_LaunchVelocity
BSS f32 Munchlesia_LateralVelocity
BSS f32 Munchlesia_LaunchYaw
BSS s32 D_802B62E0

◆ action_update_use_tweester()

void action_update_use_tweester ( void )

Definition at line 14 of file use_tweester.c.

14 {
15 PlayerStatus* playerStatus = &gPlayerStatus;
16 f32 sinAngle, cosAngle, liftoffVelocity;
17 Entity* entity;
18
20 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
21 playerStatus->flags &= ~PS_FLAG_ACTION_STATE_CHANGED;
24 playerStatus->flags |= (PS_FLAG_ROTATION_LOCKED | PS_FLAG_FLYING);
25 suggest_player_anim_allow_backward(ANIM_MarioW2_FlailArms);
26 playerStatus->actionSubstate = SUBSTATE_LAUNCH;
28 PlayerTweesterPhysicsPtr->radius = fabsf(dist2D(playerStatus->pos.x, playerStatus->pos.z, entity->pos.x, entity->pos.z));
29 PlayerTweesterPhysicsPtr->angle = atan2(entity->pos.x, entity->pos.z, playerStatus->pos.x, playerStatus->pos.z);
34 }
35
36 switch (playerStatus->actionSubstate) {
37 case SUBSTATE_LAUNCH:
39
40 playerStatus->pos.x = entity->pos.x + (sinAngle * PlayerTweesterPhysicsPtr->radius);
41 playerStatus->pos.z = entity->pos.z - (cosAngle * PlayerTweesterPhysicsPtr->radius);
42
44
45 if (PlayerTweesterPhysicsPtr->radius > 20.0f) {
47 } else if (PlayerTweesterPhysicsPtr->radius < 19.0f) {
49 }
50
55 }
56
57 playerStatus->pos.y += liftoffVelocity;
62 }
64 playerStatus->actionSubstate++; // SUBSTATE_DONE
65 entity_start_script(entity);
66 }
67 break;
68 case SUBSTATE_DONE:
71 playerStatus->blinkTimer = 50;
74 playerStatus->flags &= ~(PS_FLAG_ROTATION_LOCKED | PS_FLAG_FLYING);
76 break;
77 }
78}
@ SOUND_TWEESTER_LAUNCH
Definition enums.h:1080
s32 entity_start_script(Entity *entity)
Definition entity.c:560
void disable_player_shadow(void)
Definition 77480.c:968
void disable_npc_shadow(Npc *npc)
Definition npc.c:1037
Npc * wPartnerNpc
Definition partners.c:43
TweesterPhysics * PlayerTweesterPhysicsPtr
Definition use_tweester.c:7
@ SUBSTATE_LAUNCH
@ SUBSTATE_DONE
Entity * TweesterTouchingPlayer
Definition 7B440.c:6

◆ action_update_state_23()

void action_update_state_23 ( void )

Definition at line 32 of file misc.c.

32 {
33 PlayerStatus* playerStatus = &gPlayerStatus;
34 f32 hitDirZ;
35 f32 hitDirX;
36 f32 hitRz;
37 f32 hitRx;
38 f32 outLength;
39 f32 outZ;
40 f32 outY;
41 f32 outX;
42 f32 cosTheta;
43 f32 sinTheta;
44 f32 miscTempVariable;
45 f32 playerXOffset;
46 f32 playerZOffset;
47 f32 zDelta;
48 f32 playerOffsetTempVar;
49
50 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
52 playerStatus->actionSubstate = 0;
53 playerStatus->curStateTime = 0;
54 playerStatus->timeInAir = 0;
55 playerStatus->peakJumpTime = 0;
56 playerStatus->curSpeed = 0.0f;
57 playerStatus->pitch = 0.0f;
59 }
60
61 switch (playerStatus->actionSubstate) {
62 case 0:
63 playerStatus->actionSubstate++;
64 case 1:
65 break;
66 default:
67 return;
68 }
69
70 sin_cos_rad(DEG_TO_RAD(PlayerNormalPitch), &sinTheta, &cosTheta);
71
72 miscTempVariable = 3.0f;
73 miscTempVariable = sinTheta * miscTempVariable;
74
75 sin_cos_rad(DEG_TO_RAD(D_802B6770_E27C80), &sinTheta, &cosTheta);
76
77 playerXOffset = sinTheta * miscTempVariable;
78 playerZOffset = cosTheta * miscTempVariable;
79
80 if (fabs(playerXOffset) < 0.1) {
81 playerOffsetTempVar = 0.1f;
82 if (playerXOffset < 0.0f) {
83 playerOffsetTempVar = -0.1f;
84 }
85 playerXOffset = playerOffsetTempVar;
86 }
87
88 if (fabs(playerZOffset) < 0.1) {
89 playerOffsetTempVar = 0.1f;
90 if (playerZOffset < 0.0f) {
91 playerOffsetTempVar = -0.1f;
92 }
93 playerZOffset = playerOffsetTempVar;
94 }
95
96 playerStatus->pos.x += playerXOffset;
97 playerStatus->pos.z -= playerZOffset;
98 outX = playerStatus->pos.x;
99 outY = playerStatus->pos.y;
100 outZ = playerStatus->pos.z;
101 outLength = 5.0f;
102 if (player_raycast_below_cam_relative(playerStatus, &outX, &outY, &outZ, &outLength, &hitRx, &hitRz, &hitDirX, &hitDirZ) >= 0) {
103 playerStatus->pos.y = outY;
104 }
105
107 miscTempVariable = 30.0f;
108 } else {
109 miscTempVariable = 60.0f;
110 }
111
112 if (PlayerNormalPitch < miscTempVariable) {
115 }
116}
@ AREA_SBK
Definition enums.h:2970
@ ACTION_STATE_FALLING
Definition enums.h:2435
void gravity_use_fall_parms(void)
Definition 7BB60.c:302
BSS f32 D_802B6770_E27C80
Definition misc.c:7
f32 PlayerNormalPitch
Definition 7B440.c:10
f32 PlayerNormalYaw
Definition 7B440.c:9

Variable Documentation

◆ PlayerActionsTable

Action PlayerActionsTable[]

Definition at line 77 of file actions.c.

77 {
115 //@bug function does not exist in world_action_walk, causes jump to middle of action_update_run and crashes
118};
void action_update_pushing_block(void)
Definition misc.c:182
void action_update_talk(void)
Definition misc.c:214
#define ACTION_FILE(name)
Definition actions.c:75
void action_update_step_down(void)
Definition jump.c:141
void action_update_knockback(void)
Definition knockback.c:9
void action_update_use_tweester(void)
void action_update_jump(void)
Definition jump.c:41
void action_update_sliding(void)
Definition slide.c:38
void action_update_step_up_peach(void)
Definition step_up.c:85
void action_update_idle(void)
Definition idle.c:36
void action_update_use_spinning_flower(void)
void action_update_raise_arms(void)
Definition misc.c:163
void action_update_first_strike(void)
Definition misc.c:142
void action_update_spin_jump(void)
Definition spin_jump.c:18
void action_update_hit_lava(void)
Definition hit_lava.c:19
void action_update_launch(void)
Definition misc.c:118
void action_update_use_munchlesia(void)
void action_update_state_23(void)
Definition misc.c:32
void action_update_run(void)
Definition walk.c:111
void action_update_walk(void)
Definition walk.c:30
void action_update_hit_fire(void)
Definition hit_fire.c:9
void action_update_landing_on_switch(void)
Definition jump.c:76
void action_update_hammer(void)
Definition hammer.c:230
void action_update_land(void)
Definition land.c:12
void action_update_spin(void)
Definition spin.c:27
void action_update_parasol(void)
void action_update_falling(void)
Definition jump.c:114
void action_update_tornado_jump(void)
void action_update_step_up(void)
Definition step_up.c:29
void action_update_ride(void)
Definition misc.c:9
void action_update_step_down_land(void)
Definition land.c:77
@ ACTION_STATE_PUSHING_BLOCK
Definition enums.h:2448
@ ACTION_STATE_RIDE
Definition enums.h:2461
@ ACTION_STATE_24
Definition enums.h:2464
@ ACTION_STATE_STEP_DOWN_LAND
Definition enums.h:2438
@ ACTION_STATE_USE_MUNCHLESIA
Set by the jan_09 squishy flower entity; throws the player in the air.
Definition enums.h:2458
@ ACTION_STATE_SPIN_JUMP
Definition enums.h:2441
@ ACTION_STATE_TALK
Reading signs doesn't count.
Definition enums.h:2440
@ ACTION_STATE_23
Definition enums.h:2463
@ ACTION_STATE_USE_TWEESTER
Definition enums.h:2459
@ ACTION_STATE_USE_SPRING
Definition enums.h:2466
@ ACTION_STATE_USE_SNEAKY_PARASOL
Definition enums.h:2453
@ ACTION_STATE_BOUNCE_OFF_SWITCH
Small red/blue ! switches.
Definition enums.h:2460
@ ACTION_STATE_STEP_UP_PEACH
Definition enums.h:2452
@ ACTION_STATE_USE_SPINNING_FLOWER
Definition enums.h:2457
@ ACTION_STATE_INVALID_25
Definition enums.h:2465
@ ACTION_STATE_SLIDING
Definition enums.h:2445
@ ACTION_STATE_HOP
Released A before apex of jump.
Definition enums.h:2432
@ ACTION_STATE_KNOCKBACK
Definition enums.h:2450
@ ACTION_STATE_ENEMY_FIRST_STRIKE
Definition enums.h:2455
@ ACTION_STATE_13
Definition enums.h:2447
@ ACTION_STATE_BOUNCE
Used with Kooper.
Definition enums.h:2431
@ ACTION_STATE_STEP_DOWN
Definition enums.h:2436
@ ACTION_STATE_HAMMER
Definition enums.h:2446
@ ACTION_STATE_HIT_FIRE
Causes Mario to fly up and take damage. Used for fire bars.
Definition enums.h:2449
@ ACTION_STATE_TORNADO_JUMP
Definition enums.h:2443
@ ACTION_STATE_STEP_UP
Definition enums.h:2462

Referenced by phys_peach_update(), and phys_update_action_state().