Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
hit_fire.c
Go to the documentation of this file.
1#include "common.h"
2#include "sprite/player.h"
3
4enum {
7};
8
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}
f32 gravityIntegrator[4]
#define atan2
@ PS_FLAG_FALLING
Definition enums.h:3036
@ PS_FLAG_ENTERING_BATTLE
Definition enums.h:3061
@ PS_FLAG_ACTION_STATE_CHANGED
Definition enums.h:3084
@ PS_FLAG_FLYING
Definition enums.h:3037
@ PS_FLAG_HIT_FIRE
Definition enums.h:3050
@ HAZARD_TYPE_NONE
Definition enums.h:3499
@ PA_FLAG_INTERRUPT_USE_PARTNER
forces actions with bow, parakarry, watt, and lakilester to end (sushie not tested)
Definition enums.h:3093
@ ACTION_STATE_LAND
Definition enums.h:2437
@ CAMERA_MOVE_IGNORE_PLAYER_Y
Definition enums.h:4732
@ GLOBAL_OVERRIDES_40
Definition enums.h:4325
@ CAM_DEFAULT
Definition enums.h:1800
f32 integrate_gravity(void)
Definition 7BB60.c:436
void suggest_player_anim_always_forward(AnimID anim)
Definition 77480.c:913
s32 get_collider_flags(s32 colliderID)
Definition collision.c:481
f32 player_check_collision_below(f32, s32 *colliderID)
Definition 7BB60.c:470
void set_action_state(s32 actionState)
Definition 7E9D0.c:209
void subtract_hp(s32 amt)
Definition inventory.c:2192
void sin_cos_rad(f32 rad, f32 *outSinTheta, f32 *outCosTheta)
Definition 43F0.c:706
f32 get_xz_dist_to_player(f32, f32)
Definition 77480.c:960
void open_status_bar_slowly(void)
Definition inventory.c:1420
f32 player_fall_distance(void)
Definition 7BB60.c:461
@ SUBSTATE_FALLING
Definition hit_fire.c:6
@ SUBSTATE_FLYING
Definition hit_fire.c:5
void action_update_hit_fire(void)
Definition hit_fire.c:9
#define DEG_TO_RAD(deg)
Definition macros.h:134
#define NO_COLLIDER
Definition macros.h:156
s32 gOverrideFlags
Definition main_loop.c:11
Camera gCameras[4]
Definition cam_main.c:17
PlayerStatus gPlayerStatus
Definition 77480.c:39