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

Go to the source code of this file.

Functions

ApiStatus player_jump (Evt *script, s32 isInitialCall, s32 mode)
 Internal function for PlayerJump(), PlayerJump1(), and PlayerJump2().
 
s32 func_802D23F8 (void)
 

Variables

Npc playerNpcData
 
u16 PlayerImgFXFlags
 
s32 D_802DB5B4 [3]
 
NpcplayerNpc = &playerNpcData
 

Function Documentation

◆ player_jump()

ApiStatus player_jump ( Evt * script,
s32 isInitialCall,
s32 mode )

Internal function for PlayerJump(), PlayerJump1(), and PlayerJump2().

Definition at line 214 of file player_api.c.

214 {
215 Bytecode* args = script->ptrReadPos;
216 PlayerStatus* playerStatus = &gPlayerStatus;
217 f32 xTemp;
218 f32 yTemp;
219 f32 zTemp;
220 f32 jumpVel;
221 s32 duration;
222 AnimID anim;
223 f32 dist;
224
225 if (isInitialCall) {
226 script->functionTemp[0] = 0;
227 }
228
229 if (script->functionTemp[0] == 0) {
230 xTemp = evt_get_variable(script, *args++);
231 yTemp = evt_get_variable(script, *args++);
232 zTemp = evt_get_variable(script, *args++);
233 duration = evt_get_variable(script, *args++);
234
235 playerNpc->pos.x = playerStatus->pos.x;
236 playerNpc->pos.y = playerStatus->pos.y;
237 playerNpc->pos.z = playerStatus->pos.z;
238 playerNpc->moveToPos.x = xTemp;
239 playerNpc->moveToPos.y = yTemp;
240 playerNpc->moveToPos.z = zTemp;
241 playerNpc->duration = duration;
242 playerNpc->yaw = playerStatus->targetYaw;
243
245 if (dist > 1.0) {
247 }
248
249 yTemp = playerNpc->moveToPos.y - playerNpc->pos.y;
250
251 if (playerNpc->duration == 0) {
253 } else {
255 }
256
258 playerStatus->flags |= PS_FLAG_FLYING;
259 playerStatus->animFlags |= PA_FLAG_NO_OOB_RESPAWN;
260
261 if (mode == 0) {
262 if (!(playerStatus->animFlags & PA_FLAG_8BIT_MARIO)) {
263 if (!(playerStatus->animFlags & PA_FLAG_USING_WATT)) {
264 anim = ANIM_Mario1_Jump;
265 } else {
266 anim = ANIM_MarioW1_JumpWatt;
267 }
268 } else {
269 anim = ANIM_MarioW3_8bit_Jump;
270 }
273 }
274 script->functionTemp[0] = 1;
275 }
276
279 jumpVel = playerNpc->jumpVel; // TODO: temp needed and used specifically only once below for this to match
281
282 if (mode == 0 && jumpVel > 0.0f && playerNpc->jumpVel <= 0.0f) {
283 if (!(playerStatus->animFlags & PA_FLAG_8BIT_MARIO)) {
284 if (!(playerStatus->animFlags & PA_FLAG_USING_WATT)) {
285 anim = ANIM_Mario1_Fall;
286 } else {
287 anim = ANIM_MarioW1_FallWatt;
288 }
289 } else {
290 anim = ANIM_MarioW3_8bit_Jump;
291 }
293 }
294
295 playerStatus->pos.x = playerNpc->pos.x;
296 playerStatus->pos.y = playerNpc->pos.y;
297 playerStatus->pos.z = playerNpc->pos.z;
298
299 if (mode == 0) {
300 playerStatus->targetYaw = playerNpc->yaw;
301 }
302
304 if (playerNpc->duration == 0) {
305 playerStatus->flags &= ~PS_FLAG_FLYING;
306 playerStatus->animFlags &= ~PA_FLAG_NO_OOB_RESPAWN;
307
308 if (mode == 0) {
309 if (!(playerStatus->animFlags & PA_FLAG_8BIT_MARIO)) {
310 if (!(playerStatus->animFlags & PA_FLAG_USING_WATT)) {
311 anim = ANIM_Mario1_Land;
312 } else {
313 anim = ANIM_MarioW1_LandWatt;
314 }
315 } else {
316 anim = ANIM_Mario1_TiredIdle;
317 }
320 }
321
322 if (mode == 0 || mode == 2) {
323 s32 colliderID;
324
325 yTemp = player_check_collision_below(playerNpc->jumpVel, &colliderID);
326
327 if (colliderID > NO_COLLIDER) {
328 playerStatus->pos.y = yTemp;
331 }
332 }
333 return ApiStatus_DONE1;
334 }
335 return ApiStatus_BLOCK;
336}
Bytecode * ptrReadPos
u32 AnimID
#define atan2
@ PS_FLAG_FLYING
Definition enums.h:3037
@ PA_FLAG_NO_OOB_RESPAWN
Definition enums.h:3121
@ PA_FLAG_8BIT_MARIO
Definition enums.h:3105
@ PA_FLAG_USING_WATT
Definition enums.h:3090
@ SOUND_QUICK_PLAYER_JUMP
Definition enums.h:1424
@ SURFACE_INTERACT_LAND
Definition enums.h:4686
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737
s32 Bytecode
Definition evt.h:7
#define ApiStatus_DONE1
Definition evt.h:117
#define ApiStatus_BLOCK
Definition evt.h:116
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
f32 player_check_collision_below(f32, s32 *colliderID)
Definition 7BB60.c:470
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
void player_handle_floor_collider_type(s32 colliderID)
Definition 7BB60.c:326
void suggest_player_anim_allow_backward(AnimID anim)
Definition 77480.c:894
void player_surface_spawn_fx(void)
Definition surfaces.c:42
void npc_surface_spawn_fx(Npc *npc, SurfaceInteractMode mode)
Definition surfaces.c:394
void npc_move_heading(Npc *npc, f32 speed, f32 yaw)
Definition npc.c:986
Npc * playerNpc
Definition player_api.c:12
void sfx_play_sound_at_player(s32 soundID, s32 arg1)
Definition sfx.c:521
#define NO_COLLIDER
Definition macros.h:156
f32 jumpScale
f32 jumpVel
Vec3f moveToPos
Vec3f pos
f32 moveSpeed
s16 duration
PlayerStatus gPlayerStatus
Definition 77480.c:39

◆ func_802D23F8()

s32 func_802D23F8 ( void )

Definition at line 582 of file player_api.c.

582 {
587 return TRUE;
588 }
589 return FALSE;
590}
@ ACTION_STATE_STEP_DOWN_LAND
Definition enums.h:2438
@ ACTION_STATE_SPIN_POUND
Definition enums.h:2442
@ ACTION_STATE_IDLE
Definition enums.h:2426
@ ACTION_STATE_TORNADO_POUND
Definition enums.h:2444
@ ACTION_STATE_LAND
Definition enums.h:2437
@ ACTION_STATE_WALK
Definition enums.h:2427
@ ACTION_STATE_SPIN
Definition enums.h:2454
@ ACTION_STATE_RUN
Definition enums.h:2428

Variable Documentation

◆ playerNpcData

Npc playerNpcData
extern

Definition at line 43 of file script_list.c.

◆ PlayerImgFXFlags

u16 PlayerImgFXFlags
extern

Definition at line 44 of file script_list.c.

◆ D_802DB5B4

s32 D_802DB5B4[3]
extern

◆ playerNpc

Npc* playerNpc = &playerNpcData

Definition at line 12 of file player_api.c.

Referenced by player_jump().