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

Go to the source code of this file.

Enumerations

enum  {
  SUBSTATE_ATTRACT = 1 , SUBSTATE_EJECT = 2 , SUBSTATE_SPIN_UP = 3 , SUBSTATE_ASCEND_A = 4 ,
  SUBSTATE_ASCEND_B = 5 , SUBSTATE_BOOST = 10 , SUBSTATE_FINISH = 11
}
 

Functions

void action_update_use_spinning_flower (void)
 

Variables

BSS s32 SpinningFlower_EntityIndex
 
BSS f32 D_802B6ED4
 
BSS f32 D_802B6ED8
 
BSS f32 D_802B6EDC
 
BSS f32 D_802B6EE0
 
BSS f32 D_802B6EE4
 
BSS f32 D_802B6EE8
 
BSS f32 SpinningFlower_AngleToCenter
 
BSS f32 D_802B6EF0
 
BSS f32 D_802B6EF4
 
Vec3s FlowerGoalPosition
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SUBSTATE_ATTRACT 
SUBSTATE_EJECT 
SUBSTATE_SPIN_UP 
SUBSTATE_ASCEND_A 
SUBSTATE_ASCEND_B 
SUBSTATE_BOOST 
SUBSTATE_FINISH 

Definition at line 17 of file use_spinning_flower.c.

17 {
23 SUBSTATE_BOOST = 10,
24 SUBSTATE_FINISH = 11,
25};
@ SUBSTATE_EJECT
@ SUBSTATE_ATTRACT
@ SUBSTATE_ASCEND_A
@ SUBSTATE_ASCEND_B
@ SUBSTATE_BOOST
@ SUBSTATE_FINISH
@ SUBSTATE_SPIN_UP

Function Documentation

◆ 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]
#define clamp_angle
#define atan2
@ BUTTON_Z
Definition enums.h:2788
@ PS_FLAG_ROTATION_LOCKED
Definition enums.h:3065
@ PS_FLAG_ACTION_STATE_CHANGED
Definition enums.h:3084
@ PS_FLAG_SCRIPTED_FALL
Definition enums.h:3071
@ PA_FLAG_WATT_IN_HANDS
Definition enums.h:3092
@ PA_FLAG_USING_WATT
Definition enums.h:3090
@ ACTION_STATE_LAND
Definition enums.h:2437
@ GLOBAL_OVERRIDES_40
Definition enums.h:4325
@ CAM_DEFAULT
Definition enums.h:1800
void start_falling(void)
Definition 7E9D0.c:293
Entity * get_entity_by_index(s32 index)
Definition entity.c:530
f32 fabsf(f32 f)
void suggest_player_anim_always_forward(AnimID anim)
Definition 77480.c:913
s32 disable_player_input(void)
Definition 77480.c:990
f32 player_check_collision_below(f32, s32 *colliderID)
Definition 7BB60.c:470
s32 disable_player_static_collisions(void)
Definition 77480.c:972
s32 enable_player_input(void)
Definition 77480.c:998
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
s32 phys_adjust_cam_on_landing(void)
Definition 7E9D0.c:46
void game_input_to_move_vector(f32 *x, f32 *y)
Definition 7B440.c:162
void set_action_state(s32 actionState)
Definition 7E9D0.c:209
void enable_partner_ai(void)
Definition partners.c:2390
void suggest_player_anim_allow_backward(AnimID anim)
Definition 77480.c:894
void exec_entity_commandlist(Entity *entity)
Definition entity.c:313
void collision_lava_reset_check_additional_overlaps(void)
Definition 7BB60.c:990
f32 sin_rad(f32 x)
Definition 43F0.c:713
s32 enable_player_static_collisions(void)
Definition 77480.c:980
void sin_cos_rad(f32 rad, f32 *outSinTheta, f32 *outCosTheta)
Definition 43F0.c:706
void func_800EF300(void)
Definition partners.c:2382
#define COLLISION_WITH_ENTITY_BIT
Definition macros.h:152
#define DEG_TO_RAD(deg)
Definition macros.h:134
#define NO_COLLIDER
Definition macros.h:156
Vec3f targetPos
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
s32 gOverrideFlags
Definition main_loop.c:11
CollisionStatus gCollisionStatus
Definition 7BB60.c:6
GameStatus * gGameStatusPtr
Definition main_loop.c:32
Camera gCameras[4]
Definition cam_main.c:17
PlayerStatus gPlayerStatus
Definition 77480.c:39

Variable Documentation

◆ SpinningFlower_EntityIndex

BSS s32 SpinningFlower_EntityIndex

Definition at line 4 of file use_spinning_flower.c.

Referenced by action_update_use_spinning_flower().

◆ D_802B6ED4

BSS f32 D_802B6ED4

Definition at line 5 of file use_spinning_flower.c.

Referenced by action_update_use_spinning_flower().

◆ D_802B6ED8

BSS f32 D_802B6ED8

Definition at line 6 of file use_spinning_flower.c.

Referenced by action_update_use_spinning_flower().

◆ D_802B6EDC

BSS f32 D_802B6EDC

Definition at line 7 of file use_spinning_flower.c.

Referenced by action_update_use_spinning_flower().

◆ D_802B6EE0

BSS f32 D_802B6EE0

Definition at line 8 of file use_spinning_flower.c.

Referenced by action_update_use_spinning_flower().

◆ D_802B6EE4

BSS f32 D_802B6EE4

Definition at line 9 of file use_spinning_flower.c.

Referenced by action_update_use_spinning_flower().

◆ D_802B6EE8

BSS f32 D_802B6EE8

Definition at line 10 of file use_spinning_flower.c.

Referenced by action_update_use_spinning_flower().

◆ SpinningFlower_AngleToCenter

BSS f32 SpinningFlower_AngleToCenter

Definition at line 11 of file use_spinning_flower.c.

Referenced by action_update_use_spinning_flower().

◆ D_802B6EF0

BSS f32 D_802B6EF0

Definition at line 12 of file use_spinning_flower.c.

Referenced by action_update_use_spinning_flower().

◆ D_802B6EF4

BSS f32 D_802B6EF4

Definition at line 13 of file use_spinning_flower.c.

Referenced by action_update_use_spinning_flower().

◆ FlowerGoalPosition

Vec3s FlowerGoalPosition
extern

Definition at line 24 of file Plants1.c.

Referenced by action_update_use_spinning_flower(), and func_802BB000_E2D930().