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

Go to the source code of this file.

Functions

void action_update_walk (void)
 
void action_update_run (void)
 
void action_update_walk_set_peach_anim (void)
 

Variables

AnimID WalkPeachAnims []
 

Function Documentation

◆ 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
u32 AnimID
@ PS_FLAG_ACTION_STATE_CHANGED
Definition enums.h:3084
@ PS_FLAG_CUTSCENE_MOVEMENT
Definition enums.h:3054
@ PS_FLAG_ARMS_RAISED
Definition enums.h:3063
@ PS_FLAG_SCRIPTED_FALL
Definition enums.h:3071
@ PA_FLAG_80000000
Definition enums.h:3127
@ 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
@ ABILITY_SLOW_GO
Definition enums.h:447
@ ACTION_STATE_IDLE
Definition enums.h:2426
@ ACTION_STATE_RUN
Definition enums.h:2428
s32 is_ability_active(s32 arg0)
Definition inventory.c:1725
f32 fabsf(f32 f)
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
void try_player_footstep_sounds(s32 arg0)
Definition 7BB60.c:1105
b32 check_input_jump(void)
Definition 7E9D0.c:344
#define SQ(x)
Definition macros.h:166
s32 D_800F7B44
Definition 7E9D0.c:32
s32 PrevPlayerCamRelativeYaw
Definition 7E9D0.c:31
PlayerData gPlayerData
Definition 77480.c:40
PlayerStatus gPlayerStatus
Definition 77480.c:39

◆ 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
@ ACTION_STATE_WALK
Definition enums.h:2427
s32 PlayerRunStateTime
Definition 7B440.c:8

◆ action_update_walk_set_peach_anim()

void action_update_walk_set_peach_anim ( void )

Definition at line 202 of file walk.c.

202 {
206 suggest_player_anim_allow_backward(ANIM_Peach3_WalkSad);
207 } else {
209 }
210}
DisguiseAnims BasicPeachDisguiseAnims[]
Definition 7E9D0.c:464
@ PEACH_FLAG_DEPRESSED
Definition enums.h:2492
@ PA_FLAG_INVISIBLE
Definition enums.h:3104
void peach_set_disguise_anim(AnimID)
Definition 7E9D0.c:506
GameStatus gGameStatus
Definition main_loop.c:21
AnimID WalkPeachAnims[]
Definition walk.c:5

Variable Documentation

◆ WalkPeachAnims

AnimID WalkPeachAnims[]
Initial value:
= {
[PEACH_BAKING_NONE] ANIM_Peach1_Walk,
[PEACH_BAKING_CREAM] ANIM_Peach1_CarryCream,
[PEACH_BAKING_STRAWBERRY] ANIM_Peach1_CarryStrawberry,
[PEACH_BAKING_BUTTER] ANIM_Peach1_CarryButter,
[PEACH_BAKING_CLEANSER] ANIM_Peach1_CarryCleanser,
[PEACH_BAKING_WATER] ANIM_Peach1_CarryWater,
[PEACH_BAKING_MILK] ANIM_Peach1_CarryMilk,
[PEACH_BAKING_FLOUR] ANIM_Peach1_CarryFlour,
[PEACH_BAKING_EGG] ANIM_Peach1_CarryEgg,
[PEACH_BAKING_COMPLETE_CAKE] ANIM_Peach1_CarryCompleteCake,
[PEACH_BAKING_CAKE_BOWL] ANIM_Peach1_CarryCakeBowl,
[PEACH_BAKING_CAKE_MIXED] ANIM_Peach1_CarryCakeMixed,
[PEACH_BAKING_CAKE_PAN] ANIM_Peach1_CarryCakePan,
[PEACH_BAKING_CAKE_BATTER] ANIM_Peach1_CarryCakeBatter,
[PEACH_BAKING_CAKE_BARE] ANIM_Peach1_CarryBareCake,
[PEACH_BAKING_SALT] ANIM_Peach1_CarrySalt,
[PEACH_BAKING_SUGAR] ANIM_Peach1_CarrySugar,
[PEACH_BAKING_CAKE_WITH_ICING] ANIM_Peach1_CarryIcingCake,
[PEACH_BAKING_CAKE_WITH_BERRIES] ANIM_Peach1_CarryBerryCake,
}
@ PEACH_BAKING_CAKE_MIXED
Definition enums.h:2507
@ PEACH_BAKING_CAKE_BOWL
Definition enums.h:2506
@ PEACH_BAKING_BUTTER
Definition enums.h:2499
@ PEACH_BAKING_CAKE_WITH_ICING
Definition enums.h:2513
@ PEACH_BAKING_NONE
Definition enums.h:2496
@ PEACH_BAKING_WATER
Definition enums.h:2501
@ PEACH_BAKING_COMPLETE_CAKE
Definition enums.h:2505
@ PEACH_BAKING_FLOUR
Definition enums.h:2503
@ PEACH_BAKING_SUGAR
Definition enums.h:2512
@ PEACH_BAKING_CAKE_PAN
Definition enums.h:2508
@ PEACH_BAKING_STRAWBERRY
Definition enums.h:2498
@ PEACH_BAKING_CAKE_WITH_BERRIES
Definition enums.h:2514
@ PEACH_BAKING_EGG
Definition enums.h:2504
@ PEACH_BAKING_CAKE_BATTER
Definition enums.h:2509
@ PEACH_BAKING_MILK
Definition enums.h:2502
@ PEACH_BAKING_CLEANSER
Definition enums.h:2500
@ PEACH_BAKING_SALT
Definition enums.h:2511
@ PEACH_BAKING_CAKE_BARE
Definition enums.h:2510
@ PEACH_BAKING_CREAM
Definition enums.h:2497

Definition at line 5 of file walk.c.

5 {
6 [PEACH_BAKING_NONE] ANIM_Peach1_Walk,
7 [PEACH_BAKING_CREAM] ANIM_Peach1_CarryCream,
8 [PEACH_BAKING_STRAWBERRY] ANIM_Peach1_CarryStrawberry,
9 [PEACH_BAKING_BUTTER] ANIM_Peach1_CarryButter,
10 [PEACH_BAKING_CLEANSER] ANIM_Peach1_CarryCleanser,
11 [PEACH_BAKING_WATER] ANIM_Peach1_CarryWater,
12 [PEACH_BAKING_MILK] ANIM_Peach1_CarryMilk,
13 [PEACH_BAKING_FLOUR] ANIM_Peach1_CarryFlour,
14 [PEACH_BAKING_EGG] ANIM_Peach1_CarryEgg,
15 [PEACH_BAKING_COMPLETE_CAKE] ANIM_Peach1_CarryCompleteCake,
16 [PEACH_BAKING_CAKE_BOWL] ANIM_Peach1_CarryCakeBowl,
17 [PEACH_BAKING_CAKE_MIXED] ANIM_Peach1_CarryCakeMixed,
18 [PEACH_BAKING_CAKE_PAN] ANIM_Peach1_CarryCakePan,
19 [PEACH_BAKING_CAKE_BATTER] ANIM_Peach1_CarryCakeBatter,
20 [PEACH_BAKING_CAKE_BARE] ANIM_Peach1_CarryBareCake,
21 [PEACH_BAKING_SALT] ANIM_Peach1_CarrySalt,
22 [PEACH_BAKING_SUGAR] ANIM_Peach1_CarrySugar,
23 [PEACH_BAKING_CAKE_WITH_ICING] ANIM_Peach1_CarryIcingCake,
24 [PEACH_BAKING_CAKE_WITH_BERRIES] ANIM_Peach1_CarryBerryCake,
25};

Referenced by action_update_walk_set_peach_anim().