From f0145e8541d95a53d29f47307afbe88bfe406833 Mon Sep 17 00:00:00 2001 From: HailSanta <53960937+HailSanta@users.noreply.github.com> Date: Thu, 16 Mar 2023 02:41:26 -0400 Subject: [PATCH] other world partners (#981) * watt * half sushie * sushie * laki first pass * checkpoint * ok * PartnerStatus * enough * minor --------- Co-authored-by: HailSanta --- include/common_structs.h | 13 +- include/dead.h | 2 +- include/effects.h | 18 +- include/enums.h | 7 +- include/functions.h | 13 +- include/variables.h | 2 +- src/17D6A0.c | 2 +- src/182B30.c | 2 +- src/23680.c | 10 +- src/38F00.c | 4 +- src/77480.c | 35 +- src/7E9D0.c | 12 +- src/7bb60_len_41b0.c | 30 +- src/7fd10_len_b40.c | 47 +- src/C50A0.c | 4 +- src/audio/sfx.c | 6 +- src/battle/area/mac/actor/lee.c | 12 +- src/battle/common/actor/ghost_watt.inc.c | 12 +- src/battle/partner/watt.c | 12 +- src/camera.c | 2 +- src/effects/ice_pillar.c | 2 +- src/effects/static_status.c | 168 +-- src/encounter.c | 20 +- src/encounter_api.c | 2 +- src/entity/Switch.c | 4 +- src/entity/jan_iwa/Plants1.c | 6 +- src/entity/sbk_omo/StarBoxLauncher.c | 2 +- src/entity/sbk_omo/Tweester.c | 4 +- src/evt/npc_api.c | 10 +- src/evt/player_api.c | 2 +- src/i_spy.c | 8 +- src/msg.c | 14 +- src/npc.c | 26 +- src/npc_collision.c | 16 +- src/pulse_stone.c | 6 +- src/state_startup.c | 2 +- src/world/action/idle.c | 6 +- src/world/action/misc.c | 30 +- src/world/action/sneaky_parasol.c | 4 +- src/world/action/step_up.c | 2 +- src/world/action/walk.c | 2 +- src/world/area_end/common/Credits.inc.c | 2 +- src/world/area_flo/flo_13/flo_13_4_npc.c | 4 +- src/world/area_gv/gv_01/gv_01_1_main.c | 2 +- .../area_hos/hos_00/hos_00_7_shade_gfx.c | 2 +- src/world/area_hos/hos_05/hos_05_5_intro.c | 2 +- src/world/area_isk/isk_06/isk_06_4_switch.c | 10 +- src/world/area_isk/isk_12/isk_12_4_switch.c | 10 +- src/world/area_jan/jan_04/jan_04_10_demo.c | 4 +- src/world/area_jan/jan_11/jan_11_3_npc.c | 2 +- src/world/area_kgr/kgr_02/kgr_02_3_npc.c | 4 +- src/world/area_kmr/kmr_00/kmr_00_3_revival.c | 9 +- src/world/area_kmr/kmr_20/kmr_20_13_records.c | 4 +- .../area_kpa/kpa_12/kpa_12_3_platforms.c | 2 +- .../area_kpa/kpa_13/kpa_13_4_platforms.c | 2 +- src/world/area_kpa/kpa_14/kpa_14_2_main.c | 4 +- .../area_kpa/kpa_14/kpa_14_4_platforms.c | 2 +- src/world/area_kzn/common/SpinyTromp.inc.c | 4 +- .../area_kzn/kzn_02/kzn_02_2_platforms.c | 2 +- src/world/area_kzn/kzn_08/kzn_08_4_extra.c | 2 +- .../area_kzn/kzn_11/kzn_11_2_platforms.c | 2 +- .../area_mac/mac_04/npc_toybox_shyguy.inc.c | 2 +- src/world/area_mim/mim_12/mim_12_5_gate.c | 8 +- .../area_obk/obk_07/obk_07_6_phonograph.c | 2 +- .../area_omo/omo_09/omo_09_3_conveyors.c | 16 +- src/world/area_omo/omo_14/omo_14_3_npc.c | 6 +- src/world/common/atomic/CreateDarkness.inc.c | 2 +- src/world/common/enemy/ai/CleftAI.inc.c | 2 +- .../common/enemy/ai/ClubbaNappingAI.inc.c | 6 +- src/world/common/enemy/ai/FireBarAI.inc.c | 8 +- .../common/enemy/ai/MagikoopaSpellAI.inc.c | 6 +- src/world/common/enemy/ai/MeleeHitbox.inc.c | 4 +- src/world/common/enemy/ai/MontyMoleAI.inc.c | 2 +- .../common/enemy/ai/PiranhaPlantAI.inc.c | 4 +- .../common/enemy/ai/ProjectileHitbox.inc.c | 4 +- src/world/common/enemy/ai/SentinelAI.inc.c | 4 +- src/world/common/enemy/ai/SwooperAI.inc.c | 2 +- src/world/common/entity/SuperBlock.inc.c | 2 +- .../common/todo/StarSpiritEffectFunc.inc.c | 12 +- .../common/todo/WaitForPlayerToLand.inc.c | 2 +- src/world/dead/area_flo/flo_13/flo_13_4_npc.c | 4 +- .../dead/area_kzn/kzn_11/kzn_11_2_platforms.c | 2 +- src/world/partner/bombette.c | 30 +- src/world/partner/bow.c | 33 +- src/world/partner/goombario.c | 22 +- src/world/partner/goombario.h | 1 - src/world/partner/kooper.c | 30 +- src/world/partner/lakilester.c | 1086 ++++++++-------- src/world/partner/lakilester.h | 5 +- src/world/partner/parakarry.c | 106 +- src/world/partner/sushie.c | 1116 +++++++++-------- src/world/partner/sushie.h | 4 +- src/world/partner/watt.c | 449 +++---- src/world/partner/watt.h | 4 +- src/world/partners.c | 152 +-- src/world/partners.h | 2 +- src/world/script_api/enter_exit.c | 26 +- .../C50A0/test_item_player_collision.s | 4 +- ver/ique/symbol_addrs.txt | 2 +- ver/ique/undefined_syms.txt | 4 +- ver/jp/symbol_addrs.txt | 2 +- ver/jp/undefined_syms.txt | 2 +- ver/pal/undefined_syms.txt | 4 +- ver/us/asm/bss2_2.s | 2 +- .../C50A0/test_item_player_collision.s | 4 +- ver/us/symbol_addrs.txt | 156 ++- ver/us/undefined_syms.txt | 2 +- 107 files changed, 2044 insertions(+), 1960 deletions(-) diff --git a/include/common_structs.h b/include/common_structs.h index f5465c7883..a9eee451e0 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -26,6 +26,7 @@ typedef void NoArgCallback(void*); typedef s32 b32; typedef s8 b8; +typedef s32 HitID; typedef u32 AnimID; typedef struct { @@ -235,7 +236,7 @@ typedef struct Npc { /* 0x034 */ f32 renderYaw; /* 0x038 */ Vec3f pos; /* 0x044 */ Vec3f rotation; - /* 0x050 */ f32 rotationVerticalPivotOffset; + /* 0x050 */ f32 rotationPivotOffsetY; /* 0x054 */ Vec3f scale; /* 0x060 */ Vec3f moveToPos; /* 0x06C */ Vec3f colliderPos; /* used during collision with player */ @@ -2248,22 +2249,22 @@ typedef struct TweesterPhysics { /* 0x18 */ f32 liftoffVelocityPhase; } TweesterPhysics; // size = 0x1C -typedef struct PartnerActionStatus { +typedef struct PartnerStatus { /* 0x000 */ s8 partnerActionState; - /* 0x001 */ b8 partnerAction_unk_1; - /* 0x002 */ s8 partnerAction_unk_2; + /* 0x001 */ b8 shouldResumeAbility; + /* 0x002 */ b8 partnerAction_unk_2; /* 0x003 */ s8 actingPartner; /* 0x004 */ s16 stickX; /* 0x006 */ s16 stickY; /* 0x008 */ s32 currentButtons; /* 0x00C */ s32 pressedButtons; /* 0x010 */ s32 heldButtons; - /* 0x014 */ s8 inputDisabled; + /* 0x014 */ s8 inputDisabledCount; /* 0x015 */ char unk_15[3]; /* 0x018 */ Npc npc; /* 0x358 */ s32 unk_358; /* 0x35C */ char unk_35C[0x4]; -} PartnerActionStatus; // size = 0x360 +} PartnerStatus; // size = 0x360 typedef struct SpriteRasterInfo { /* 0x00 */ IMG_PTR raster; diff --git a/include/dead.h b/include/dead.h index 1ee0b3fe41..54fac40713 100644 --- a/include/dead.h +++ b/include/dead.h @@ -40,7 +40,7 @@ #define gCurrentCameraID dead_gCurrentCameraID #define add_vec2D_polar dead_add_vec2D_polar #define gCurrentCamID dead_gCurrentCamID -#define gPartnerActionStatus dead_gPartnerActionStatus +#define gPartnerStatus dead_gPartnerStatus #define get_npc_safe dead_get_npc_safe #define sfx_adjust_env_sound_pos dead_sfx_adjust_env_sound_pos #define fx_star_spirits_energy dead_fx_star_spirits_energy diff --git a/include/effects.h b/include/effects.h index 49f01a269a..47b71e948f 100644 --- a/include/effects.h +++ b/include/effects.h @@ -2228,20 +2228,18 @@ typedef struct MiscParticlesFXData { } MiscParticlesFXData; // size = 0x64 typedef struct StaticStatusFXData { - /* 0x00 */ s32 unk_00; - /* 0x04 */ f32 unk_04; - /* 0x08 */ f32 unk_08; - /* 0x0C */ f32 unk_0C; + /* 0x00 */ s32 type; + /* 0x04 */ Vec3f pos; /* 0x10 */ f32 unk_10; /* 0x14 */ f32 unk_14; /* 0x18 */ f32 unk_18; /* 0x1C */ f32 unk_1C; - /* 0x20 */ s32 unk_20; - /* 0x24 */ f32 unk_24; - /* 0x28 */ s32 unk_28; - /* 0x2C */ s32 unk_2C; - /* 0x30 */ s32 unk_30; - /* 0x34 */ f32 unk_34; + /* 0x20 */ s32 frame; // not visible when negative + /* 0x24 */ f32 rotation; + /* 0x28 */ s32 timeLeft; + /* 0x2C */ s32 lifetime; + /* 0x30 */ s32 alpha; + /* 0x34 */ f32 scale; } StaticStatusFXData; // size = 0x38 typedef struct MovingCloudFXData { diff --git a/include/enums.h b/include/enums.h index 30e791a24b..9b395a89e8 100644 --- a/include/enums.h +++ b/include/enums.h @@ -2341,14 +2341,14 @@ enum PlayerAnims { ANIM_MarioB3_Hammer2_Charged = 0x00050007, ANIM_MarioB3_Hammer3_Charging = 0x00050008, ANIM_MarioB3_Hammer3_Charged = 0x00050009, - ANIM_MarioW1_Carry = 0x00060000, + ANIM_MarioW1_CarryWalk = 0x00060000, ANIM_MarioW1_CarryAbove = 0x00060001, ANIM_MarioW1_CarryRun = 0x00060002, ANIM_MarioW1_CarryAboveRun = 0x00060003, ANIM_MarioW1_PushToward = 0x00060004, ANIM_MarioW1_TakeItem = 0x00060005, ANIM_MarioW1_PlaceItem = 0x00060006, - ANIM_MarioW1_PlaceRecord = 0x00060007, + ANIM_MarioW1_CarryIdle = 0x00060007, ANIM_MarioW1_TakeItemSquashed = 0x00060008, ANIM_MarioW1_JumpWatt = 0x00060009, ANIM_MarioW1_FallWatt = 0x0006000A, @@ -3709,7 +3709,7 @@ enum PlayerStatusAnimFlags { /* This allows dismounting from Lakilester, even if in a precarious situation (like over spikes, lava, or water). */ PA_FLAG_DISMOUNTING_ALLOWED = 0x20000000, /* This flag is set when partner usage was interrupted by a script, and it prevents menu sounds (like the error sound) from playing for script-initiated player actions */ - PA_FLAG_PARTNER_USAGE_STOPPED = 0x40000000, + PA_FLAG_FORCED_PARTNER_ABILITY_END = 0x40000000, /* This one's really weird. Seems to have something to do with the direction Mario is facing, but I'm not sure what it's actually supposed to be achieving. */ PA_FLAG_80000000 = 0x80000000, }; @@ -5368,6 +5368,7 @@ enum ColliderFlags { SURFACE_TYPE_LAVA = 3, SURFACE_TYPE_SPIKES = 2, SURFACE_TYPE_WATER = 1, + SURFACE_TYPE_INVALID = -1, COLLIDER_FLAG_SAFE_FLOOR = 0x00000100, COLLIDER_FLAG_IGNORE_SHELL = 0x00008000, diff --git a/include/functions.h b/include/functions.h index 6031d5387b..c6373e262e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -230,7 +230,7 @@ void phys_main_collision_below(void); void phys_peach_update(void); void check_input_spin(void); -s32 npc_test_move_simple_without_slipping(s32, f32*, f32*, f32*, f32, f32, f32, f32); +b32 npc_test_move_simple_without_slipping(s32, f32*, f32*, f32*, f32, f32, f32, f32); void update_collider_transform(s16 colliderID); void get_collider_center(s32 colliderID, f32* x, f32* y, f32* z); @@ -403,19 +403,19 @@ s32 create_shadow_type(s32 type, f32 x, f32 y, f32 z); s32 is_point_within_region(s32 shape, f32 pointX, f32 pointY, f32 centerX, f32 centerY, f32 sizeX, f32 sizeZ); PlayerData* get_player_data(void); -s32 npc_raycast_down_around(s32, f32*, f32*, f32*, f32*, f32, f32); +b32 npc_raycast_down_around(s32, f32*, f32*, f32*, f32*, f32, f32); s32 npc_raycast_down_sides(s32 ignoreFlags, f32* posX, f32* posY, f32* posZ, f32* hitDepth); s32 npc_raycast_up(s32, f32*, f32*, f32*, f32*); s32 npc_raycast_up_corners(s32 ignoreFlags, f32* posX, f32* posY, f32* posZ, f32* hitDepth, f32 yaw, f32 radius); s32 player_raycast_up_corners(PlayerStatus*, f32*, f32*, f32*, f32*, f32); s32 player_raycast_below_cam_relative(PlayerStatus* playerStatus, f32* outX, f32* outY, f32* outZ, f32* outLength, f32* hitRx, f32* hitRz, f32* hitDirX, f32* hitDirZ); -s32 npc_test_move_taller_with_slipping(s32, f32*, f32*, f32*, f32, f32, f32, f32); -s32 npc_test_move_simple_with_slipping(s32, f32*, f32*, f32*, f32, f32, f32, f32); +b32 npc_test_move_taller_with_slipping(s32, f32*, f32*, f32*, f32, f32, f32, f32); +b32 npc_test_move_simple_with_slipping(s32, f32*, f32*, f32*, f32, f32, f32, f32); s32 npc_test_move_complex_with_slipping(s32, f32*, f32*, f32*, f32, f32, f32, f32); // Partner -EvtScript* partner_get_ride_script(void); +EvtScript* partner_get_enter_map_script(void); void partner_handle_before_battle(void); void partner_walking_update_player_tracking(Npc* partner); void partner_walking_update_motion(Npc* partner); @@ -759,9 +759,6 @@ void pulse_stone_notification_setup(void); void appendGfx_speech_bubble(void); void appendGfx_pulse_stone_icon(void); void ispy_notification_setup(void); -s32 lakilester_raycast_below(void); -void world_watt_sync_held_position(void); -void func_802BFB44_323694(f32 arg0); void initialize_curtains(void); void update_curtains(void); diff --git a/include/variables.h b/include/variables.h index dd3d1aa2e5..2bb07fb43f 100644 --- a/include/variables.h +++ b/include/variables.h @@ -257,7 +257,7 @@ extern s32 D_802EC390[]; extern s32 D_802EC3B0[]; extern s32 D_802EC3D0[]; -extern PartnerActionStatus gPartnerActionStatus; // something with partners +extern PartnerStatus gPartnerStatus; extern UiStatus gUIStatus; extern PlayerStatus gPlayerStatus; extern PlayerSpinState gPlayerSpinState; diff --git a/src/17D6A0.c b/src/17D6A0.c index e14bf98931..3c5daca6e3 100644 --- a/src/17D6A0.c +++ b/src/17D6A0.c @@ -3398,7 +3398,7 @@ void btl_update_message_popup(void* data) { case BTL_MSG_40: case BTL_MSG_41: hud_element_set_script(D_8029F642, &HES_PressAButton); - /* fallthrough */ + // fallthrough case BTL_MSG_2E: case BTL_MSG_30: case BTL_MSG_3C: diff --git a/src/182B30.c b/src/182B30.c index 2757749ead..dd457fe804 100644 --- a/src/182B30.c +++ b/src/182B30.c @@ -3256,7 +3256,7 @@ void func_8025C918(s32 isNpcSprite, ActorPart* part, s32 yaw, s32 arg3) { baseAngle = decor->unk75C; if (decor->unk75C >= 360) { - decor->unk75C = baseAngle - ((baseAngle / 360) * 360); + decor->unk75C = baseAngle % 360; } for (i = 0; i < ARRAY_COUNT(rbuf); i++) { diff --git a/src/23680.c b/src/23680.c index eaf077e7c4..e8f73140a3 100644 --- a/src/23680.c +++ b/src/23680.c @@ -417,7 +417,7 @@ s32 is_point_within_region(s32 shape, f32 pointX, f32 pointY, f32 centerX, f32 c s32 basic_ai_check_player_dist(EnemyDetectVolume* territory, Enemy* enemy, f32 radius, f32 fwdPosOffset, s8 useWorldYaw) { Npc* npc = get_npc_unsafe(enemy->npcID); PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus; + PartnerStatus* partnerStatus; f32 x, y, z; f32 dist; s32 skipCheckForPlayer; @@ -426,13 +426,13 @@ s32 basic_ai_check_player_dist(EnemyDetectVolume* territory, Enemy* enemy, f32 r return FALSE; } - partnerActionStatus = &gPartnerActionStatus; - if (partnerActionStatus->actingPartner == PARTNER_BOW && partnerActionStatus->partnerActionState + partnerStatus = &gPartnerStatus; + if (partnerStatus->actingPartner == PARTNER_BOW && partnerStatus->partnerActionState && !(territory->detectFlags & AI_TERRITORY_IGNORE_HIDING)) { return FALSE; } - if (partnerActionStatus->actingPartner == PARTNER_SUSHIE && partnerActionStatus->partnerActionState + if (partnerStatus->actingPartner == PARTNER_SUSHIE && partnerStatus->partnerActionState && !(territory->detectFlags & AI_TERRITORY_IGNORE_HIDING)) { return FALSE; } @@ -463,7 +463,7 @@ s32 basic_ai_check_player_dist(EnemyDetectVolume* territory, Enemy* enemy, f32 r y = npc->pos.y + npc->collisionHeight * 0.5; z = npc->pos.z; dist = dist2D(npc->pos.x, npc->pos.z, playerStatus->position.x, playerStatus->position.z); - if (npc_test_move_simple_with_slipping(0x50000, + if (npc_test_move_simple_with_slipping(COLLISION_CHANNEL_10000 | COLLISION_IGNORE_ENTITIES, &x, &y, &z, dist, atan2(npc->pos.x, npc->pos.z, playerStatus->position.x, playerStatus->position.z), 0.1f, 0.1f)) { diff --git a/src/38F00.c b/src/38F00.c index 1384900777..989d640873 100644 --- a/src/38F00.c +++ b/src/38F00.c @@ -89,11 +89,11 @@ ApiStatus func_8005DB00(Evt* script, s32 isInitialCall) { Npc* npc; f32 targetDir, npcYaw; PlayerStatus* playerStatus; - PartnerActionStatus* partnerStatus; + PartnerStatus* partnerStatus; npc = get_npc_unsafe(script->owner1.enemy->npcID); playerStatus = &gPlayerStatus; - partnerStatus = &gPartnerActionStatus; + partnerStatus = &gPartnerStatus; if (isInitialCall) { script->functionTemp[0] = 0; diff --git a/src/77480.c b/src/77480.c index 98ef5d360a..5b54f55800 100644 --- a/src/77480.c +++ b/src/77480.c @@ -2,6 +2,7 @@ #include "ld_addrs.h" #include "world/actions.h" #include "sprite.h" +#include "world/partner/watt.h" #ifdef SHIFT #define inspect_icon_VRAM_DEF inspect_icon_VRAM @@ -781,12 +782,12 @@ void player_reset_data(void) { } s32 func_800DFCF4(void) { - if (gPartnerActionStatus.partnerActionState == PARTNER_ACTION_USE && - (gPartnerActionStatus.actingPartner == PARTNER_WATT - || gPartnerActionStatus.actingPartner == PARTNER_BOW - || gPartnerActionStatus.actingPartner == PARTNER_SUSHIE - || gPartnerActionStatus.actingPartner == PARTNER_PARAKARRY - || gPartnerActionStatus.actingPartner == PARTNER_LAKILESTER)) { + if (gPartnerStatus.partnerActionState == PARTNER_ACTION_USE && + (gPartnerStatus.actingPartner == PARTNER_WATT + || gPartnerStatus.actingPartner == PARTNER_BOW + || gPartnerStatus.actingPartner == PARTNER_SUSHIE + || gPartnerStatus.actingPartner == PARTNER_PARAKARRY + || gPartnerStatus.actingPartner == PARTNER_LAKILESTER)) { return FALSE; } return TRUE; @@ -794,7 +795,7 @@ s32 func_800DFCF4(void) { s32 get_overriding_player_anim(s32 anim) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; if (playerStatus->actionState == ACTION_STATE_USE_SPINNING_FLOWER && anim != ANIM_Mario1_Flail @@ -803,13 +804,13 @@ s32 get_overriding_player_anim(s32 anim) { return -1; } - if (partnerActionStatus->partnerActionState != PARTNER_ACTION_NONE) { - if (partnerActionStatus->actingPartner == PARTNER_LAKILESTER && anim == ANIM_Mario1_Idle) { + if (partnerStatus->partnerActionState != PARTNER_ACTION_NONE) { + if (partnerStatus->actingPartner == PARTNER_LAKILESTER && anim == ANIM_Mario1_Idle) { anim = ANIM_MarioW2_RideLaki; } - if (partnerActionStatus->partnerActionState != PARTNER_ACTION_NONE - && partnerActionStatus->actingPartner == PARTNER_BOW + if (partnerStatus->partnerActionState != PARTNER_ACTION_NONE + && partnerStatus->actingPartner == PARTNER_BOW && anim != ANIM_Mario1_Crouch && anim != ANIM_Mario1_Idle ) { @@ -817,7 +818,7 @@ s32 get_overriding_player_anim(s32 anim) { } } - if (anim == ANIM_Mario1_ThumbsUp && partnerActionStatus->partnerActionState == PARTNER_ACTION_USE) { + if (anim == ANIM_Mario1_ThumbsUp && partnerStatus->partnerActionState == PARTNER_ACTION_USE) { return -1; } @@ -882,8 +883,8 @@ void update_player_blink(void) { u8 phi_v1; u8* alpha; - if (gPartnerActionStatus.actingPartner == PARTNER_BOW) { - outtaSight = gPartnerActionStatus.partnerActionState != PARTNER_ACTION_NONE; + if (gPartnerStatus.actingPartner == PARTNER_BOW) { + outtaSight = gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE; } if (playerStatus->blinkTimer > 0) { @@ -977,7 +978,7 @@ s32 game_scripts_disabled(void) { s32 ret = FALSE; if (gGameStatusPtr->disableScripts && (gGameStatusPtr->currentButtons[0] & BUTTON_R)) { - if (gPartnerActionStatus.partnerActionState == PARTNER_ACTION_NONE) { + if (gPartnerStatus.partnerActionState == PARTNER_ACTION_NONE) { set_action_state(ACTION_STATE_IDLE); } ret = TRUE; @@ -1042,7 +1043,7 @@ void check_for_pulse_stone(void) { return; } - if (gPlayerStatus.flags & PS_FLAG_PAUSED || gPlayerStatus.inputDisabledCount) { + if (gPlayerStatus.flags & PS_FLAG_PAUSED || gPlayerStatus.inputDisabledCount != 0) { return; } @@ -1127,7 +1128,7 @@ s32 func_800E06D8(void) { s32 interactingID = playerStatus->interactingWithID; s32 currentWall; - if (playerStatus->timeInAir != 0 || playerStatus->inputDisabledCount) { + if (playerStatus->timeInAir != 0 || playerStatus->inputDisabledCount != 0) { return FALSE; } if (gCollisionStatus.currentWall == NO_COLLIDER) { diff --git a/src/7E9D0.c b/src/7E9D0.c index 6d81a5789f..c84a69e8bf 100644 --- a/src/7E9D0.c +++ b/src/7E9D0.c @@ -27,7 +27,7 @@ void func_800E5520(void) { } s32 phys_adjust_cam_on_landing(void) { - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; GameStatus* gameStatus = gGameStatusPtr; PlayerStatus* playerStatus = &gPlayerStatus; s32 ret = 1; @@ -160,7 +160,7 @@ s32 phys_adjust_cam_on_landing(void) { } else { gCameras[CAM_DEFAULT].moveFlags &= ~CAMERA_MOVE_IGNORE_PLAYER_Y; } - } else if (partnerActionStatus->partnerActionState != PARTNER_ACTION_NONE && partnerActionStatus->actingPartner == PARTNER_PARAKARRY) { + } else if (partnerStatus->partnerActionState != PARTNER_ACTION_NONE && partnerStatus->actingPartner == PARTNER_PARAKARRY) { gCameras[CAM_DEFAULT].moveFlags |= CAMERA_MOVE_FLAG_2; } else { gCameras[CAM_DEFAULT].moveFlags &= ~CAMERA_MOVE_FLAG_2; @@ -215,7 +215,7 @@ void phys_reset_spin_history(void) { void phys_update_action_state(void) { Camera* cameras = gCameras; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; PlayerStatus* playerStatus = &gPlayerStatus; PlayerSpinState* playerSpinState = &gPlayerSpinState; @@ -266,7 +266,7 @@ void phys_update_action_state(void) { cond = FALSE; } - if ((partnerActionStatus->partnerActionState == PARTNER_ACTION_NONE) && !(playerStatus->flags & PS_FLAG_PAUSED) && cond) { + if ((partnerStatus->partnerActionState == PARTNER_ACTION_NONE) && !(playerStatus->flags & PS_FLAG_PAUSED) && cond) { set_action_state(ACTION_STATE_TALK); } check_input_spin(); @@ -364,7 +364,7 @@ void set_action_state(s32 actionState) { partner = playerData->currentPartner; if (partner == PARTNER_SUSHIE || partner == PARTNER_LAKILESTER || partner == PARTNER_PARAKARRY) { - if (gPartnerActionStatus.partnerActionState != PARTNER_ACTION_NONE) { + if (gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE) { playerStatus->animFlags |= PA_FLAG_INTERRUPT_USE_PARTNER; playerStatus->flags |= PS_FLAG_HIT_FIRE; return; @@ -455,7 +455,7 @@ s32 check_input_hammer(void) { return FALSE; } - if (gPartnerActionStatus.partnerActionState == PARTNER_ACTION_USE && playerData->currentPartner == PARTNER_WATT) { + if (gPartnerStatus.partnerActionState == PARTNER_ACTION_USE && playerData->currentPartner == PARTNER_WATT) { return FALSE; } diff --git a/src/7bb60_len_41b0.c b/src/7bb60_len_41b0.c index a2580ecad8..eb4feef291 100644 --- a/src/7bb60_len_41b0.c +++ b/src/7bb60_len_41b0.c @@ -18,7 +18,7 @@ void record_jump_apex(void) { s32 can_trigger_loading_zone(void) { PlayerData* playerData = &gPlayerData; s32 actionState = gPlayerStatusPtr->actionState; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; if (actionState == ACTION_STATE_IDLE || actionState == ACTION_STATE_WALK || @@ -31,17 +31,17 @@ s32 can_trigger_loading_zone(void) { if (actionState == ACTION_STATE_RIDE) { if (playerData->currentPartner == PARTNER_LAKILESTER || playerData->currentPartner == PARTNER_BOW) { - if (partnerActionStatus->partnerActionState != PARTNER_ACTION_NONE) { + if (partnerStatus->partnerActionState != PARTNER_ACTION_NONE) { return TRUE; } else { gPlayerStatusPtr->animFlags |= PA_FLAG_INTERRUPT_USE_PARTNER; return FALSE; } } else { - if (partnerActionStatus->actingPartner == PARTNER_WATT || partnerActionStatus->actingPartner == PARTNER_SUSHIE) { - return partnerActionStatus->partnerActionState != PARTNER_ACTION_NONE; + if (partnerStatus->actingPartner == PARTNER_WATT || partnerStatus->actingPartner == PARTNER_SUSHIE) { + return partnerStatus->partnerActionState != PARTNER_ACTION_NONE; } - if (partnerActionStatus->actingPartner == PARTNER_PARAKARRY) { + if (partnerStatus->actingPartner == PARTNER_PARAKARRY) { gPlayerStatusPtr->animFlags |= PA_FLAG_INTERRUPT_USE_PARTNER; return FALSE; } @@ -334,7 +334,7 @@ void phys_update_falling(void) { void player_handle_floor_collider_type(s32 colliderID) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; if (colliderID >= 0) { s32 surfaceType = get_collider_flags(colliderID) & COLLIDER_FLAGS_SURFACE_TYPE_MASK; @@ -345,7 +345,7 @@ void player_handle_floor_collider_type(s32 colliderID) { set_action_state(ACTION_STATE_LAND); break; case SURFACE_TYPE_LAVA: - if ((*(s32*)(&partnerActionStatus->partnerActionState) & 0xFF0000FF) != 0x01000009) { + if ((*(s32*)(&partnerStatus->partnerActionState) & 0xFF0000FF) != 0x01000009) { if (playerStatus->blinkTimer == 0) { if (playerStatus->actionState != ACTION_STATE_HIT_LAVA) { playerStatus->hazardType = HAZARD_TYPE_LAVA; @@ -357,7 +357,7 @@ void player_handle_floor_collider_type(s32 colliderID) { } break; case SURFACE_TYPE_SPIKES: - if ((*(s32*)(&partnerActionStatus->partnerActionState) & 0xFF0000FF) != 0x01000009) { + if ((*(s32*)(&partnerStatus->partnerActionState) & 0xFF0000FF) != 0x01000009) { if (playerStatus->blinkTimer == 0) { if (playerStatus->actionState != ACTION_STATE_HIT_FIRE) { playerStatus->hazardType = HAZARD_TYPE_SPIKES; @@ -877,7 +877,7 @@ s32 phys_is_on_sloped_ground(void) { void phys_main_collision_below(void) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; CollisionStatus* collisionStatus = &gCollisionStatus; f32 collHeightHalf = playerStatus->colliderHeight * 0.5f; f32 playerX = playerStatus->position.x; @@ -925,7 +925,7 @@ void phys_main_collision_below(void) { s32 surfaceType = get_collider_flags(colliderID) & COLLIDER_FLAGS_SURFACE_TYPE_MASK; switch (surfaceType) { case SURFACE_TYPE_SPIKES: - if (partnerActionStatus->partnerActionState == PARTNER_ACTION_NONE || partnerActionStatus->actingPartner != PARTNER_BOW) { + if (partnerStatus->partnerActionState == PARTNER_ACTION_NONE || partnerStatus->actingPartner != PARTNER_BOW) { if (playerStatus->blinkTimer == 0) { if (playerStatus->actionState != ACTION_STATE_HIT_LAVA) { playerStatus->hazardType = HAZARD_TYPE_SPIKES; @@ -937,7 +937,7 @@ void phys_main_collision_below(void) { } break; case SURFACE_TYPE_LAVA: - if (partnerActionStatus->partnerActionState == PARTNER_ACTION_NONE || partnerActionStatus->actingPartner != PARTNER_BOW) { + if (partnerStatus->partnerActionState == PARTNER_ACTION_NONE || partnerStatus->actingPartner != PARTNER_BOW) { if (playerStatus->blinkTimer == 0) { if (playerStatus->actionState != ACTION_STATE_HIT_LAVA) { playerStatus->hazardType = HAZARD_TYPE_LAVA; @@ -1165,13 +1165,13 @@ s32 phys_check_interactable_collision(void) { } s32 phys_can_player_interact(void) { - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; PlayerStatus* playerStatus = &gPlayerStatus; s32 ret = TRUE; - if (gPartnerActionStatus.partnerActionState != PARTNER_ACTION_NONE) { - if (gPartnerActionStatus.actingPartner == PARTNER_BOMBETTE) { - if (gPartnerActionStatus.partnerActionState <= PARTNER_ACTION_BOMBETTE_2) { + if (gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE) { + if (gPartnerStatus.actingPartner == PARTNER_BOMBETTE) { + if (gPartnerStatus.partnerActionState <= PARTNER_ACTION_BOMBETTE_2) { ret = FALSE; } } else { diff --git a/src/7fd10_len_b40.c b/src/7fd10_len_b40.c index 8b558cf75c..be6a6c5d6d 100644 --- a/src/7fd10_len_b40.c +++ b/src/7fd10_len_b40.c @@ -6,6 +6,7 @@ #include "sprite.h" #include "pause/pause_common.h" #include "world/partners.h" +#include "world/partner/lakilester.h" BSS s16 D_8010C9C0; BSS char D_8010C9C4[0x4]; @@ -27,7 +28,7 @@ extern s32 D_8008EEF0[]; void func_800E6860(void) { PlayerStatus* playerStatus = &gPlayerStatus; - if (gPartnerActionStatus.partnerActionState != PARTNER_ACTION_NONE && gPartnerActionStatus.actingPartner == PARTNER_BOW) { + if (gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE && gPartnerStatus.actingPartner == PARTNER_BOW) { Npc* partner = get_npc_unsafe(NPC_PARTNER); func_802DDEE4(PLAYER_SPRITE_MAIN, -1, FOLD_TYPE_7, 0, 0, 0, playerStatus->alpha1, 0); @@ -37,7 +38,7 @@ void func_800E6860(void) { } s32 func_800E6904(void) { - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; PlayerStatus* playerStatus = &gPlayerStatus; s32 actionState = playerStatus->actionState; @@ -45,20 +46,20 @@ s32 func_800E6904(void) { return FALSE; } - if (partnerActionStatus->partnerActionState == PARTNER_ACTION_NONE) { + if (partnerStatus->partnerActionState == PARTNER_ACTION_NONE) { if (!(playerStatus->flags & PS_FLAG_NO_STATIC_COLLISION) && (actionState == ACTION_STATE_IDLE || actionState == ACTION_STATE_WALK || actionState == ACTION_STATE_RUN)) { return TRUE; } } else if (partner_player_can_pause()) { - if (partnerActionStatus->actingPartner == PARTNER_WATT) { + if (partnerStatus->actingPartner == PARTNER_WATT) { return TRUE; - } else if (partnerActionStatus->actingPartner == PARTNER_BOW) { + } else if (partnerStatus->actingPartner == PARTNER_BOW) { if (actionState == ACTION_STATE_RIDE) { return TRUE; } - } else if (partnerActionStatus->actingPartner == PARTNER_LAKILESTER) { + } else if (partnerStatus->actingPartner == PARTNER_LAKILESTER) { if (actionState == ACTION_STATE_RIDE) { return TRUE; } @@ -69,7 +70,7 @@ s32 func_800E6904(void) { } s32 can_pause(s32 currentButtons, s32 pressedButtons) { - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; s32 actionState = gPlayerStatus.actionState; if (!(gPlayerStatus.animFlags & PA_FLAG_CHANGING_MAP) @@ -81,7 +82,7 @@ s32 can_pause(s32 currentButtons, s32 pressedButtons) { && !is_picking_up_item() ) { if (!(gPlayerStatus.animFlags & PA_FLAG_8BIT_MARIO)) { - if (partnerActionStatus->partnerActionState == PARTNER_ACTION_NONE) { + if (partnerStatus->partnerActionState == PARTNER_ACTION_NONE) { if (!(gPlayerStatus.flags & PS_FLAG_NO_STATIC_COLLISION)) { if (actionState == ACTION_STATE_IDLE || actionState == ACTION_STATE_WALK || @@ -91,23 +92,23 @@ s32 can_pause(s32 currentButtons, s32 pressedButtons) { } } } else if (partner_player_can_pause()) { - if (partnerActionStatus->actingPartner == PARTNER_WATT) { + if (partnerStatus->actingPartner == PARTNER_WATT) { return actionState == ACTION_STATE_IDLE || actionState == ACTION_STATE_WALK || actionState == ACTION_STATE_RUN; - } else if (partnerActionStatus->actingPartner == PARTNER_BOW) { + } else if (partnerStatus->actingPartner == PARTNER_BOW) { if (actionState == ACTION_STATE_RIDE) { gPlayerStatus.alpha2 = 0; return TRUE; } - } else if (partnerActionStatus->actingPartner == PARTNER_LAKILESTER) { + } else if (partnerStatus->actingPartner == PARTNER_LAKILESTER) { if (actionState == ACTION_STATE_RIDE) { - if (lakilester_raycast_below()) { + if (world_lakilester_can_dismount()) { return TRUE; } sfx_play_sound(SOUND_MENU_ERROR); } - } else if (partnerActionStatus->actingPartner == PARTNER_SUSHIE) { + } else if (partnerStatus->actingPartner == PARTNER_SUSHIE) { sfx_play_sound(SOUND_MENU_ERROR); } } @@ -181,7 +182,7 @@ s32 setup_item_popup(PopupMenu* menu) { void check_input_open_menus(void) { static s16 D_8010C9C0; - PartnerActionStatus* partnerActionStatus; + PartnerStatus* partnerStatus; PlayerStatus* playerStatus; PlayerData* playerData; PopupMenu* popup; @@ -191,7 +192,7 @@ void check_input_open_menus(void) { s32 currentButtons; s8* partnerActionState; - partnerActionStatus = &gPartnerActionStatus; + partnerStatus = &gPartnerStatus; playerStatus = &gPlayerStatus; playerData = &gPlayerData; popup = &D_8010C9C8; @@ -203,18 +204,18 @@ void check_input_open_menus(void) { return; } - if (partnerActionStatus->partnerActionState != 0 && - (partnerActionStatus->actingPartner == PARTNER_SUSHIE || - partnerActionStatus->actingPartner == PARTNER_LAKILESTER || - partnerActionStatus->actingPartner == PARTNER_BOW)) + if (partnerStatus->partnerActionState != 0 && + (partnerStatus->actingPartner == PARTNER_SUSHIE || + partnerStatus->actingPartner == PARTNER_LAKILESTER || + partnerStatus->actingPartner == PARTNER_BOW)) { - currentButtons = partnerActionStatus->currentButtons; - pressedButtons = partnerActionStatus->pressedButtons; + currentButtons = partnerStatus->currentButtons; + pressedButtons = partnerStatus->pressedButtons; } else { currentButtons = playerStatus->currentButtons; pressedButtons = playerStatus->pressedButtons; } - partnerActionState = &partnerActionStatus->partnerActionState; + partnerActionState = &partnerStatus->partnerActionState; if (evt_get_variable(NULL, GB_StoryProgress) >= STORY_EPILOGUE) { currentButtons &= ~(BUTTON_C_LEFT | BUTTON_C_RIGHT); @@ -274,7 +275,7 @@ block_17: break; case 1: flags = ~PS_FLAG_PAUSED; - if ((func_800E6904() == 0) || is_picking_up_item() || D_8010CCFE < playerStatus->inputDisabledCount) { + if ((func_800E6904() == 0) || is_picking_up_item() || D_8010CCFE < playerStatus->inputDisabledCount != 0) { playerStatus->flags &= flags; enable_player_input(); partner_enable_input(); diff --git a/src/C50A0.c b/src/C50A0.c index 5714558e11..c2ff0bcf42 100644 --- a/src/C50A0.c +++ b/src/C50A0.c @@ -1775,7 +1775,7 @@ void func_80133A94(s32 idx, s32 itemID) { #ifdef NON_EQUIVALENT s32 test_item_player_collision(ItemEntity* item) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; EncounterStatus* encounterStatus = &gCurrentEncounter; Camera* camera = &gCameras[gCurrentCameraID]; s32 actionState; @@ -1832,7 +1832,7 @@ s32 test_item_player_collision(ItemEntity* item) { return FALSE; } - if (partnerActionStatus->partnerActionState != 0 && partnerActionStatus->actingPartner == 9) { + if (partnerStatus->partnerActionState != 0 && partnerStatus->actingPartner == 9) { return FALSE; } diff --git a/src/audio/sfx.c b/src/audio/sfx.c index 18aa4633a0..ddb1823632 100644 --- a/src/audio/sfx.c +++ b/src/audio/sfx.c @@ -250,7 +250,7 @@ void sfx_compute_spatialized_sound_params_full(f32 x, f32 y, f32 z, s16* volume, offsetX = 0.0f; } - volAmtOffsetX = update_lerp(0, 1.0f, 0.0f, offsetX, 200); + volAmtOffsetX = update_lerp(EASING_LINEAR, 1.0f, 0.0f, offsetX, 200); if (volAmtOffsetX < 0.0) { volAmtOffsetX = 0.0f; } @@ -260,7 +260,7 @@ void sfx_compute_spatialized_sound_params_full(f32 x, f32 y, f32 z, s16* volume, offsetY = 0.0f; } - volAmtDeltaY = update_lerp(0, 1.0f, 0.0f, offsetY, 130); + volAmtDeltaY = update_lerp(EASING_LINEAR, 1.0f, 0.0f, offsetY, 130); if (volAmtDeltaY < 0.0) { volAmtDeltaY = 0.0f; } @@ -270,7 +270,7 @@ void sfx_compute_spatialized_sound_params_full(f32 x, f32 y, f32 z, s16* volume, depth = 0.0f; } - volAmtDepth = update_lerp(0, 1.0f, 0.0f, depth, 250); + volAmtDepth = update_lerp(EASING_LINEAR, 1.0f, 0.0f, depth, 250); if (volAmtDepth < 0.0) { volAmtDepth = 0.0f; } diff --git a/src/battle/area/mac/actor/lee.c b/src/battle/area/mac/actor/lee.c index 24431b5986..29db076b06 100644 --- a/src/battle/area/mac/actor/lee.c +++ b/src/battle/area/mac/actor/lee.c @@ -2914,9 +2914,9 @@ API_CALLABLE(func_80219188_465618) { wattEffectData->effect2->flags |= EFFECT_INSTANCE_FLAG_10; wattEffectData->effect2 = NULL; } - wattEffectData->effect1->data.staticStatus->unk_04 = x; - wattEffectData->effect1->data.staticStatus->unk_08 = y; - wattEffectData->effect1->data.staticStatus->unk_0C = z; + wattEffectData->effect1->data.staticStatus->pos.x = x; + wattEffectData->effect1->data.staticStatus->pos.y = y; + wattEffectData->effect1->data.staticStatus->pos.z = z; break; case 1: if (wattEffectData->effect1 != NULL) { @@ -2927,9 +2927,9 @@ API_CALLABLE(func_80219188_465618) { wattEffectData->effect2 = fx_static_status(1, x, y, z, (actor->debuff != STATUS_SHRINK) ? 1.0f : 0.4f, 5, 0); } - wattEffectData->effect2->data.staticStatus->unk_04 = x; - wattEffectData->effect2->data.staticStatus->unk_08 = y; - wattEffectData->effect2->data.staticStatus->unk_0C = z; + wattEffectData->effect2->data.staticStatus->pos.x = x; + wattEffectData->effect2->data.staticStatus->pos.y = y; + wattEffectData->effect2->data.staticStatus->pos.z = z; break; } } else { diff --git a/src/battle/common/actor/ghost_watt.inc.c b/src/battle/common/actor/ghost_watt.inc.c index 5c723dd5ad..5da0100ffa 100644 --- a/src/battle/common/actor/ghost_watt.inc.c +++ b/src/battle/common/actor/ghost_watt.inc.c @@ -45,9 +45,9 @@ API_CALLABLE(N(UnkWattEffectFunc1)) { wattEffectData->effect2->flags |= EFFECT_INSTANCE_FLAG_10; wattEffectData->effect2 = NULL; } - wattEffectData->effect1->data.staticStatus->unk_04 = x; - wattEffectData->effect1->data.staticStatus->unk_08 = y; - wattEffectData->effect1->data.staticStatus->unk_0C = z; + wattEffectData->effect1->data.staticStatus->pos.x = x; + wattEffectData->effect1->data.staticStatus->pos.y = y; + wattEffectData->effect1->data.staticStatus->pos.z = z; break; case 1: if (wattEffectData->effect1 != NULL) { @@ -58,9 +58,9 @@ API_CALLABLE(N(UnkWattEffectFunc1)) { wattEffectData->effect2 = fx_static_status(1, x, y, z, (actor->debuff != STATUS_SHRINK) ? 1.0f : 0.4f, 5, 0); } - wattEffectData->effect2->data.staticStatus->unk_04 = x; - wattEffectData->effect2->data.staticStatus->unk_08 = y; - wattEffectData->effect2->data.staticStatus->unk_0C = z; + wattEffectData->effect2->data.staticStatus->pos.x = x; + wattEffectData->effect2->data.staticStatus->pos.y = y; + wattEffectData->effect2->data.staticStatus->pos.z = z; break; } } else { diff --git a/src/battle/partner/watt.c b/src/battle/partner/watt.c index 071892f1e5..4b1156a83f 100644 --- a/src/battle/partner/watt.c +++ b/src/battle/partner/watt.c @@ -80,9 +80,9 @@ API_CALLABLE(N(WattFXUpdate)) { sWattEffectData_effect2->flags |= EFFECT_INSTANCE_FLAG_10; sWattEffectData_effect2 = NULL; } - sWattEffectData_effect1->data.staticStatus->unk_04 = x; - sWattEffectData_effect1->data.staticStatus->unk_08 = y; - sWattEffectData_effect1->data.staticStatus->unk_0C = z; + sWattEffectData_effect1->data.staticStatus->pos.x = x; + sWattEffectData_effect1->data.staticStatus->pos.y = y; + sWattEffectData_effect1->data.staticStatus->pos.z = z; break; case 1: if (sWattEffectData_effect1 != NULL) { @@ -92,9 +92,9 @@ API_CALLABLE(N(WattFXUpdate)) { if (sWattEffectData_effect2 == NULL) { sWattEffectData_effect2 = fx_static_status(1, x, y, z, 1.0f, 5, 0); } - sWattEffectData_effect2->data.staticStatus->unk_04 = x; - sWattEffectData_effect2->data.staticStatus->unk_08 = y; - sWattEffectData_effect2->data.staticStatus->unk_0C = z; + sWattEffectData_effect2->data.staticStatus->pos.x = x; + sWattEffectData_effect2->data.staticStatus->pos.y = y; + sWattEffectData_effect2->data.staticStatus->pos.z = z; break; } } else { diff --git a/src/camera.c b/src/camera.c index 9636841e4c..6aa7399348 100644 --- a/src/camera.c +++ b/src/camera.c @@ -270,7 +270,7 @@ void func_80032970(Camera* camera, f32 arg1) { camera->unk_510 = 0.0f; } else { if (gPlayerStatusPtr->animFlags & PA_FLAG_RIDING_PARTNER) { - stickX = gPartnerActionStatus.stickX; + stickX = gPartnerStatus.stickX; } else { stickX = gPlayerStatusPtr->stickAxis[0]; } diff --git a/src/effects/ice_pillar.c b/src/effects/ice_pillar.c index c4ebcc34c5..439064e9ce 100644 --- a/src/effects/ice_pillar.c +++ b/src/effects/ice_pillar.c @@ -90,7 +90,7 @@ void ice_pillar_update(EffectInstance* effect) { EffectInstance* iceShard; iceShard = ice_shard_main( - (i - ((i / 2) * 2)) + 2, + (i % 2) + 2, (data->pos.x + shim_rand_int(20)) - 10.0f, data->pos.y + (shim_rand_int(40) * data->scale), data->pos.z + 3.0f, diff --git a/src/effects/static_status.c b/src/effects/static_status.c index cfde0512c7..a3c2545a97 100644 --- a/src/effects/static_status.c +++ b/src/effects/static_status.c @@ -7,24 +7,25 @@ extern Gfx D_090003A0_3E1670[]; Gfx* D_E00E6880[] = { D_090003A0_3E1670, D_090003A0_3E1670 }; Gfx* D_E00E6888[] = { D_09000280_3E1550, D_09000280_3E1550 }; -s32 D_E00E6890[] = { 24, 12 }; +// number of frames in animation for type 0 and type 1 +s32 StaticEffectFrameCount[] = { 24, 12 }; -f32 D_E00E6898[] = { +f32 StaticEffectScaleVals0[] = { 0.9f, 1.0f, 1.0f, 0.9f, 0.85f, 0.8f, 0.75f, 0.7f, 0.65f, 0.6f, 0.55f, 0.5f, 0.45f, 0.4f, 0.35f, 0.3f, 0.25f, 0.2f, 0.15f, 0.1f, 0.05f, 0.03f, 0.02f, 0.01f }; -u8 D_E00E68F8[] = { +u8 StaticEffectAlphaVals0[] = { 0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; -f32 D_E00E6910[] = { +f32 StaticEffectScaleVals1[] = { 0.9f, 1.0f, 1.0f, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f, 0.4f, 0.3f, 0.2f, 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; -u8 D_E00E6970[] = { +u8 StaticEffectAlphaVals1[] = { 0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -35,21 +36,21 @@ void static_status_render(EffectInstance* effect); void static_status_appendGfx(void* effect); EffectInstance* static_status_main( - s32 arg0, - f32 arg1, - f32 arg2, - f32 arg3, - f32 arg4, - s32 arg5, - s32 arg6) + s32 type, + f32 x, + f32 y, + f32 z, + f32 scale, + s32 numBolts, + s32 duration) { EffectBlueprint bp; EffectInstance* effect; StaticStatusFXData* part; - f32 temp_f0; + f32 invisTime; s32 i; - arg5++; + numBolts++; bp.init = static_status_init; bp.update = static_status_update; @@ -59,28 +60,28 @@ EffectInstance* static_status_main( bp.effectID = EFFECT_STATIC_STATUS; effect = shim_create_effect_instance(&bp); - effect->numParts = arg5; - part = effect->data.staticStatus = shim_general_heap_malloc(arg5 * sizeof(*part)); + effect->numParts = numBolts; + part = effect->data.staticStatus = shim_general_heap_malloc(numBolts * sizeof(*part)); ASSERT(effect->data.staticStatus != NULL); - part->unk_00 = arg0; - part->unk_2C = 0; - if (arg6 <= 0) { - part->unk_28 = 1000; + part->type = type; + part->lifetime = 0; + if (duration <= 0) { + part->timeLeft = 1000; } else { - part->unk_28 = arg6; + part->timeLeft = duration; } - part->unk_30 = 255; - part->unk_04 = arg1; - part->unk_08 = arg2; - part->unk_0C = arg3; - part->unk_34 = arg4; + part->alpha = 255; + part->pos.x = x; + part->pos.y = y; + part->pos.z = z; + part->scale = scale; - temp_f0 = D_E00E6890[arg0] * 0.5f; + invisTime = StaticEffectFrameCount[type] * 0.5f; part++; - for (i = 1; i < arg5; i++, part++) { - part->unk_20 = -1.0f - temp_f0 * (i & 1); + for (i = 1; i < numBolts; i++, part++) { + part->frame = -1.0f - invisTime * (i & 1); } return effect; @@ -91,83 +92,82 @@ void static_status_init(EffectInstance* effect) { void static_status_update(EffectInstance* effect) { StaticStatusFXData* part = effect->data.staticStatus; - s32 unk_00 = part->unk_00; + s32 type = part->type; s32 unk_28; - s32 unk_2C; - f32 var_fs1; - f32 var_fs2; + s32 time; + f32 interpAmt; + f32 initialAmt; f32 angle; s32 i; - if (effect->flags & 0x10) { - effect->flags &= ~0x10; - part->unk_28 = 16; + if (effect->flags & EFFECT_INSTANCE_FLAG_10) { + effect->flags &= ~EFFECT_INSTANCE_FLAG_10; + part->timeLeft = 16; } - if (part->unk_28 < 1000) { - part->unk_28--; + if (part->timeLeft < 1000) { + part->timeLeft--; } - part->unk_2C++; + part->lifetime++; - if (part->unk_28 < 0) { + if (part->timeLeft < 0) { shim_remove_effect(effect); return; } - unk_28 = part->unk_28; - unk_2C = part->unk_2C; + time = part->lifetime; - if (unk_28 < 16) { - part->unk_30 = unk_28 * 16; + if (part->timeLeft < 16) { + part->alpha = part->timeLeft * 16; } - if (unk_00 == 0) { - var_fs2 = 0.1f; - var_fs1 = 0.2f; + if (type == 0) { + initialAmt = 0.1f; + interpAmt = 0.2f; } else { - var_fs2 = 0.2f; - var_fs1 = 0.2f; + initialAmt = 0.2f; + interpAmt = 0.2f; } part++; for (i = 1; i < effect->numParts; i++, part++) { - part->unk_20++; - if (part->unk_20 >= D_E00E6890[unk_00]) { - part->unk_20 = 0; + part->frame++; + if (part->frame >= StaticEffectFrameCount[type]) { + part->frame = 0; } - if (part->unk_20 >= 0) { - if (part->unk_20 == 0) { + if (part->frame >= 0) { + if (part->frame == 0) { angle = (i * 360.0f) / (effect->numParts - 1); - part->unk_04 = shim_sin_deg(angle) * 16.0f; - part->unk_08 = shim_cos_deg(angle) * 16.0f; - part->unk_10 = part->unk_04 * var_fs2; - part->unk_14 = part->unk_08 * var_fs2; + part->pos.x = shim_sin_deg(angle) * 16.0f; + part->pos.y = shim_cos_deg(angle) * 16.0f; + part->unk_10 = part->pos.x * initialAmt; + part->unk_14 = part->pos.y * initialAmt; part->unk_18 = 0.0f; part->unk_1C = 0.0f; - part->unk_34 = 1.0f; - part->unk_24 = -angle - 45.0f; + part->scale = 1.0f; + part->rotation = -angle - 45.0f; } - if (unk_00 == 0) { - part->unk_30 = D_E00E68F8[part->unk_20]; - part->unk_34 = D_E00E6898[part->unk_20]; + if (type == 0) { + part->alpha = StaticEffectAlphaVals0[part->frame]; + part->scale = StaticEffectScaleVals0[part->frame]; } else { - part->unk_30 = D_E00E6970[part->unk_20]; - part->unk_34 = D_E00E6910[part->unk_20]; + part->alpha = StaticEffectAlphaVals1[part->frame]; + part->scale = StaticEffectScaleVals1[part->frame]; } - if ((unk_2C & 1) == (i & 1)) { - part->unk_04 += part->unk_10; - part->unk_08 += part->unk_14; + if ((time & 1) == (i & 1)) { + part->pos.x += part->unk_10; + part->pos.y += part->unk_14; } else { - part->unk_04 += part->unk_10 * 0.2; - part->unk_08 += part->unk_14 * 0.2; + part->pos.x += part->unk_10 * 0.2; + part->pos.y += part->unk_14 * 0.2; } - part->unk_10 += (part->unk_18 - part->unk_10) * var_fs1; - part->unk_14 += (part->unk_1C - part->unk_14) * var_fs1; + part->unk_10 += (part->unk_18 - part->unk_10) * interpAmt; + part->unk_14 += (part->unk_1C - part->unk_14) * interpAmt; } } } @@ -191,19 +191,19 @@ void func_E00E651C(void) { void static_status_appendGfx(void* effect) { StaticStatusFXData* part = ((EffectInstance*)effect)->data.staticStatus; Camera* camera = &gCameras[gCurrentCameraID]; - s32 unk_30 = part->unk_30; - s32 unk_00 = part->unk_00; - Matrix4f sp20; - Matrix4f sp60; + s32 unk_30 = part->alpha; + s32 unk_00 = part->type; + Matrix4f mtxTransform; + Matrix4f mtxTemp; s32 i; gDPPipeSync(gMainGfxPos++); gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data)); - shim_guTranslateF(sp20, part->unk_04, part->unk_08, part->unk_0C); - shim_guScaleF(sp60, part->unk_34, part->unk_34, part->unk_34); - shim_guMtxCatF(sp60, sp20, sp20); - shim_guMtxF2L(sp20, &gDisplayContext->matrixStack[gMatrixListPos]); + shim_guTranslateF(mtxTransform, part->pos.x, part->pos.y, part->pos.z); + shim_guScaleF(mtxTemp, part->scale, part->scale, part->scale); + shim_guMtxCatF(mtxTemp, mtxTransform, mtxTransform); + shim_guMtxF2L(mtxTransform, &gDisplayContext->matrixStack[gMatrixListPos]); gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPMatrix(gMainGfxPos++, camera->unkMatrix, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); @@ -211,12 +211,12 @@ void static_status_appendGfx(void* effect) { part++; for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) { - if (part->unk_20 >= 0) { - shim_guPositionF(sp20, 0.0f, 0.0f, part->unk_24, part->unk_34, part->unk_04, part->unk_08, 0.0f); - shim_guMtxF2L(sp20, &gDisplayContext->matrixStack[gMatrixListPos]); + if (part->frame >= 0) { + shim_guPositionF(mtxTransform, 0.0f, 0.0f, part->rotation, part->scale, part->pos.x, part->pos.y, 0.0f); + shim_guMtxF2L(mtxTransform, &gDisplayContext->matrixStack[gMatrixListPos]); gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); - gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, (unk_30 * part->unk_30) >> 8); + gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, (unk_30 * part->alpha) >> 8); gSPDisplayList(gMainGfxPos++, D_E00E6880[unk_00]); gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW); } diff --git a/src/encounter.c b/src/encounter.c index b5f56303e9..e66008a3ca 100644 --- a/src/encounter.c +++ b/src/encounter.c @@ -661,7 +661,7 @@ void update_encounters_neutral(void) { gGameStatusPtr->debugEnemyContact == DEBUG_CONTACT_CANT_TOUCH || (playerStatus->flags & PS_FLAG_ARMS_RAISED) || (gOverrideFlags & GLOBAL_OVERRIDES_40) || - gPartnerActionStatus.actingPartner == PARTNER_BOW || + gPartnerStatus.actingPartner == PARTNER_BOW || (enemy->flags & ENEMY_FLAG_PASSIVE) || (gOverrideFlags & (GLOBAL_OVERRIDES_DISABLE_BATTLES | GLOBAL_OVERRIDES_200 | GLOBAL_OVERRIDES_400 | GLOBAL_OVERRIDES_800)) || is_picking_up_item()) { @@ -734,11 +734,11 @@ void update_encounters_neutral(void) { testY = npcY; testZ = npcZ; - if (npc_test_move_taller_with_slipping(COLLISION_CHANNEL_10000, &testX, &testY, &testZ, distance, atan2(npcX, npcZ, playerX, playerZ), colHeight, colRadius * 2.0f) != 0) { + if (npc_test_move_taller_with_slipping(COLLISION_CHANNEL_10000, &testX, &testY, &testZ, distance, atan2(npcX, npcZ, playerX, playerZ), colHeight, colRadius * 2.0f)) { testX = playerX; testY = playerY; testZ = playerZ; - if (npc_test_move_taller_with_slipping(COLLISION_CHANNEL_10000, &testX, &testY, &testZ, distance, atan2(playerX, playerZ, npcX, npcZ), colHeight, colRadius * 2.0f) != 0) { + if (npc_test_move_taller_with_slipping(COLLISION_CHANNEL_10000, &testX, &testY, &testZ, distance, atan2(playerX, playerZ, npcX, npcZ), colHeight, colRadius * 2.0f)) { break; } } @@ -797,11 +797,11 @@ void update_encounters_neutral(void) { testX = npcX; testY = npcY; testZ = npcZ; - if (npc_test_move_taller_with_slipping(COLLISION_CHANNEL_10000, &testX, &testY, &testZ, distance, atan2(npcX, npcZ, playerX, playerZ), colHeight, colRadius * 2.0f) != 0) { + if (npc_test_move_taller_with_slipping(COLLISION_CHANNEL_10000, &testX, &testY, &testZ, distance, atan2(npcX, npcZ, playerX, playerZ), colHeight, colRadius * 2.0f)) { testX = playerX; testY = playerY; testZ = playerZ; - if (npc_test_move_taller_with_slipping(COLLISION_CHANNEL_10000, &testX, &testY, &testZ, distance, atan2(playerX, playerZ, npcX, npcZ), colHeight, colRadius * 2.0f) != 0) { + if (npc_test_move_taller_with_slipping(COLLISION_CHANNEL_10000, &testX, &testY, &testZ, distance, atan2(playerX, playerZ, npcX, npcZ), colHeight, colRadius * 2.0f)) { break; } } @@ -882,11 +882,11 @@ void update_encounters_neutral(void) { testX = npcX; testY = npcY; testZ = npcZ; - if (npc_test_move_taller_with_slipping(COLLISION_CHANNEL_10000, &testX, &testY, &testZ, distance, atan2(npcX, npcZ, playerX, playerZ), colHeight, colRadius * 2.0f) != 0) { + if (npc_test_move_taller_with_slipping(COLLISION_CHANNEL_10000, &testX, &testY, &testZ, distance, atan2(npcX, npcZ, playerX, playerZ), colHeight, colRadius * 2.0f)) { testX = playerX; testY = playerY; testZ = playerZ; - if (npc_test_move_taller_with_slipping(COLLISION_CHANNEL_10000, &testX, &testY, &testZ, distance, atan2(playerX, playerZ, npcX, npcZ), colHeight, colRadius * 2.0f) != 0) { + if (npc_test_move_taller_with_slipping(COLLISION_CHANNEL_10000, &testX, &testY, &testZ, distance, atan2(playerX, playerZ, npcX, npcZ), colHeight, colRadius * 2.0f)) { continue; } } @@ -1570,7 +1570,7 @@ void update_encounters_post_battle(void) { EncounterStatus* currentEncounter = &gCurrentEncounter; PlayerStatus* playerStatus = &gPlayerStatus; PlayerData* playerData = &gPlayerData; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; Encounter* encounter; Evt* script; Enemy* enemy; @@ -1611,7 +1611,7 @@ void update_encounters_post_battle(void) { partner_handle_after_battle(); } D_8009A63C = FALSE; - if (partnerActionStatus->partnerAction_unk_1) { + if (partnerStatus->shouldResumeAbility) { D_8009A63C = TRUE; } else if (D_8009A670 == 0 && !(gPlayerStatus.flags & (PS_FLAG_JUMPING | PS_FLAG_FALLING)) && @@ -2281,7 +2281,7 @@ s32 check_conversation_trigger(void) { playerY = playerStatus->position.y; playerZ = playerStatus->position.z; - if (gPartnerActionStatus.partnerActionState != PARTNER_ACTION_NONE) { + if (gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE) { return FALSE; } diff --git a/src/encounter_api.c b/src/encounter_api.c index 31ce4e5b18..93f8fbcac8 100644 --- a/src/encounter_api.c +++ b/src/encounter_api.c @@ -796,7 +796,7 @@ ApiStatus GetSelfAnimationFromTable(Evt* script, s32 isInitialCall) { ApiStatus func_80045798(Evt* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - gPartnerActionStatus.unk_358 = evt_get_variable(script, *args++); + gPartnerStatus.unk_358 = evt_get_variable(script, *args++); return ApiStatus_DONE2; } diff --git a/src/entity/Switch.c b/src/entity/Switch.c index 68adc018a1..f2eaeb845d 100644 --- a/src/entity/Switch.c +++ b/src/entity/Switch.c @@ -87,7 +87,7 @@ void entity_HugeBlueSwitch_idle(Entity* entity) { void entity_small_switch_idle(Entity* entity) { SwitchData* data = entity->dataBuf.swtch; PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; entity_switch_fall_down(entity); @@ -111,7 +111,7 @@ void entity_small_switch_idle(Entity* entity) { return; } - if (partnerActionStatus->actingPartner == PARTNER_PARAKARRY && partnerActionStatus->partnerActionState != PARTNER_ACTION_NONE) { + if (partnerStatus->actingPartner == PARTNER_PARAKARRY && partnerStatus->partnerActionState != PARTNER_ACTION_NONE) { return; } diff --git a/src/entity/jan_iwa/Plants1.c b/src/entity/jan_iwa/Plants1.c index 6bf564e0a9..2d21384a44 100644 --- a/src/entity/jan_iwa/Plants1.c +++ b/src/entity/jan_iwa/Plants1.c @@ -267,7 +267,7 @@ void func_802BB98C_E2E2BC(Entity* entity) { void entity_CymbalPlant_idle(Entity* entity) { CymbalPlantData* data = entity->dataBuf.cymbalPlant; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; PlayerStatus* playerStatus = &gPlayerStatus; f32 yaw; f32 targetYaw; @@ -275,7 +275,7 @@ void entity_CymbalPlant_idle(Entity* entity) { switch (data->state) { case 0: if (entity->collisionFlags & ENTITY_COLLISION_PLAYER_TOUCH_FLOOR) { - if (partnerActionStatus->actingPartner != 0) { + if (partnerStatus->actingPartner != 0) { playerStatus->animFlags |= PA_FLAG_INTERRUPT_USE_PARTNER; } func_800EF300(); @@ -334,7 +334,7 @@ void entity_CymbalPlant_idle(Entity* entity) { } break; case 6: - if (!(entity->collisionFlags & ENTITY_COLLISION_PLAYER_TOUCH_FLOOR) && partnerActionStatus->partnerActionState == PARTNER_ACTION_NONE) { + if (!(entity->collisionFlags & ENTITY_COLLISION_PLAYER_TOUCH_FLOOR) && partnerStatus->partnerActionState == PARTNER_ACTION_NONE) { data->state = 0; enable_partner_ai(); phys_adjust_cam_on_landing(); diff --git a/src/entity/sbk_omo/StarBoxLauncher.c b/src/entity/sbk_omo/StarBoxLauncher.c index 583540d92d..41d57725bf 100644 --- a/src/entity/sbk_omo/StarBoxLauncher.c +++ b/src/entity/sbk_omo/StarBoxLauncher.c @@ -139,7 +139,7 @@ void entity_StarBoxLauncher_launch(Entity* entity) { data->faceTexOffset = D_802BCAA0_E313F0[0]; data->faceAnimTimer = D_802BCAA0_E313F0[1]; sfx_play_sound(SOUND_2085); - /* fallthrough */ + // fallthrough case 1: temp = entity->position.y; entity->position.y = temp + 8.0 * sin_rad(DEG_TO_RAD(data->riseSpeedPhase)); diff --git a/src/entity/sbk_omo/Tweester.c b/src/entity/sbk_omo/Tweester.c index 15b3645a61..5b7524ce01 100644 --- a/src/entity/sbk_omo/Tweester.c +++ b/src/entity/sbk_omo/Tweester.c @@ -201,7 +201,7 @@ void entity_Tweester_move(Entity* entity) { void entity_Tweester_idle(Entity* entity) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; PlayerData* playerData = &gPlayerData; TweesterData* data = entity->dataBuf.tweester; f32 delta; @@ -265,7 +265,7 @@ void entity_Tweester_idle(Entity* entity) { entity->rotation.y = -gCameras[CAM_DEFAULT].currentYaw; - if (partnerActionStatus->partnerActionState == PARTNER_ACTION_NONE || partnerActionStatus->actingPartner != PARTNER_BOW) { + if (partnerStatus->partnerActionState == PARTNER_ACTION_NONE || partnerStatus->actingPartner != PARTNER_BOW) { if (playerStatus->actionState == ACTION_STATE_USE_TWEESTER) { Npc* npc = npc_find_closest_simple(entity->position.x, entity->position.y, entity->position.z, 50.0f); if (npc != NULL && (npc->flags & NPC_FLAG_PARTNER)) { diff --git a/src/evt/npc_api.c b/src/evt/npc_api.c index f615213932..46e174f077 100644 --- a/src/evt/npc_api.c +++ b/src/evt/npc_api.c @@ -118,7 +118,7 @@ ApiStatus SetNpcRotationPivot(Evt* script, s32 isInitialCall) { return ApiStatus_DONE2; } - npc->rotationVerticalPivotOffset = value; + npc->rotationPivotOffsetY = value; return ApiStatus_DONE2; } @@ -952,16 +952,16 @@ ApiStatus GetCurrentPartnerID(Evt* script, s32 isInitialCall) { } ApiStatus PartnerCanUseAbility(Evt* script, s32 isInitialCall) { - Bytecode arg0 = *script->ptrReadPos; + Bytecode outVar = *script->ptrReadPos; - evt_set_variable(script, arg0, partner_can_use_ability()); + evt_set_variable(script, outVar, partner_can_use_ability()); return ApiStatus_DONE2; } ApiStatus PartnerIsFlying(Evt* script, s32 isInitialCall) { - Bytecode arg0 = *script->ptrReadPos; + Bytecode outVar = *script->ptrReadPos; - evt_set_variable(script, arg0, partner_is_flying()); + evt_set_variable(script, outVar, partner_is_flying()); return ApiStatus_DONE2; } diff --git a/src/evt/player_api.c b/src/evt/player_api.c index 45fe234fb3..d48736c199 100644 --- a/src/evt/player_api.c +++ b/src/evt/player_api.c @@ -772,7 +772,7 @@ ApiStatus GetPartnerInUse(Evt* script, s32 isInitialCall) { PlayerData* playerData = &gPlayerData; s32 currentPartner = PARTNER_NONE; - if (gPartnerActionStatus.partnerActionState != PARTNER_ACTION_NONE) { + if (gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE) { currentPartner = playerData->currentPartner; } diff --git a/src/i_spy.c b/src/i_spy.c index 7a22346911..96095c83f5 100644 --- a/src/i_spy.c +++ b/src/i_spy.c @@ -52,7 +52,7 @@ void appendGfx_ispy_icon(void) { } flashPhase = ISpyPtr->flashCount; - flashPhase = flashPhase - (flashPhase / 12) * 12; + flashPhase = flashPhase % 12; switch (flashPhase) { case 0: case 1: @@ -102,7 +102,7 @@ void ispy_notification_setup(void) { void ispy_notification_update(void) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; s32 cond; ISpyPtr->pos.y += @@ -112,8 +112,8 @@ void ispy_notification_update(void) { switch (ISpyPtr->state) { case I_SPY_DELAY: - if (partnerActionStatus->partnerActionState != PARTNER_ACTION_NONE - && partnerActionStatus->actingPartner == PARTNER_LAKILESTER + if (partnerStatus->partnerActionState != PARTNER_ACTION_NONE + && partnerStatus->actingPartner == PARTNER_LAKILESTER ) { cond = gGameStatusPtr->keepUsingPartnerOnMapChange; } else { diff --git a/src/msg.c b/src/msg.c index 60055dd6f3..d2f4bb32e0 100644 --- a/src/msg.c +++ b/src/msg.c @@ -815,7 +815,7 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) { break; case MSG_STYLE_LAMPPOST: printer->windowSize.y = *srcBuf++; - /* fallthrough */ + // fallthrough case MSG_STYLE_SIGN: do { if (!s8) { @@ -1812,20 +1812,20 @@ void get_msg_properties(s32 msgID, s32* height, s32* width, s32* maxLineChars, s break; case MSG_READ_FUNC_CUSTOM_VOICE: i++; - /* fallthrough */ + // fallthrough temp = 4; case MSG_READ_FUNC_IMAGE: i += temp; - /* fallthrough */ + // fallthrough case MSG_READ_FUNC_ANIM_SPRITE: case MSG_READ_FUNC_ANIM_DELAY: i++; - /* fallthrough */ + // fallthrough case MSG_READ_FUNC_SPEED: case MSG_READ_FUNC_SET_X: case MSG_READ_FUNC_ANIM_LOOP: i++; - /* fallthrough */ + // fallthrough case MSG_READ_FUNC_COLOR: case MSG_READ_FUNC_SPACING: case MSG_READ_FUNC_SCROLL: @@ -1897,7 +1897,7 @@ void get_msg_properties(s32 msgID, s32* height, s32* width, s32* maxLineChars, s case MSG_CHAR_READ_FULL_SPACE: case MSG_CHAR_READ_HALF_SPACE: spaceCount++; - /* fallthrough */ + // fallthrough default: if (endl) { lineCount++; @@ -2069,7 +2069,7 @@ void msg_update_rewind_arrow(s32 printerIndex) { printer->rewindArrowCounter = 0; printer->rewindArrowSwingPhase = 0; printer->rewindArrowAnimState = REWIND_ARROW_STATE_GROW; - /* fallthrough */ + // fallthrough case REWIND_ARROW_STATE_GROW: temp = printer->rewindArrowCounter; scale = temp * 0.2 + 0.5; diff --git a/src/npc.c b/src/npc.c index 6c4bfde07c..e85acbabde 100644 --- a/src/npc.c +++ b/src/npc.c @@ -121,7 +121,7 @@ s32 create_npc_impl(NpcBlueprint* blueprint, AnimID* animList, s32 isPeachNpc) { npc->colliderPos.x = 0.0f; npc->colliderPos.y = 0.0f; npc->colliderPos.z = 0.0f; - npc->rotationVerticalPivotOffset = 0.0f; + npc->rotationPivotOffsetY = 0.0f; npc->rotation.x = 0.0f; npc->rotation.y = 0.0f; npc->rotation.z = 0.0f; @@ -143,7 +143,7 @@ s32 create_npc_impl(NpcBlueprint* blueprint, AnimID* animList, s32 isPeachNpc) { npc->foldType = 0; npc->foldArg5 = 0; npc->collisionChannel = COLLISION_CHANNEL_20000; - npc->isFacingAway = 0; + npc->isFacingAway = FALSE; npc->yawCamOffset = 0; npc->turnAroundYawAdjustment = 0; npc->currentFloor = NO_COLLIDER; @@ -417,9 +417,9 @@ void npc_do_other_npc_collision(Npc* npc) { if (!(thisBuf + otherBuf <= dist)) { collision = FALSE; if (npc->flags & NPC_FLAG_PARTNER) { - collision = gPartnerActionStatus.partnerActionState == PARTNER_ACTION_NONE; + collision = gPartnerStatus.partnerActionState == PARTNER_ACTION_NONE; } else if (!(otherNpc->flags & NPC_FLAG_PARTNER) || - gPartnerActionStatus.partnerActionState == PARTNER_ACTION_NONE) + gPartnerStatus.partnerActionState == PARTNER_ACTION_NONE) { collision = TRUE; } @@ -821,8 +821,8 @@ void appendGfx_npc(void* data) { guMtxCatF(mtx2, mtx1, mtx1); } - if (npc->rotationVerticalPivotOffset != 0.0f) { - guTranslateF(mtx2, 0.0f, npc->rotationVerticalPivotOffset, 0.0f); + if (npc->rotationPivotOffsetY != 0.0f) { + guTranslateF(mtx2, 0.0f, npc->rotationPivotOffsetY, 0.0f); guMtxCatF(mtx2, mtx1, mtx1); } @@ -841,8 +841,8 @@ void appendGfx_npc(void* data) { guMtxCatF(mtx2, mtx1, mtx1); } - if (npc->rotationVerticalPivotOffset != 0.0f) { - guTranslateF(mtx2, 0.0f, -npc->rotationVerticalPivotOffset, 0.0f); + if (npc->rotationPivotOffsetY != 0.0f) { + guTranslateF(mtx2, 0.0f, -npc->rotationPivotOffsetY, 0.0f); guMtxCatF(mtx2, mtx1, mtx1); } @@ -1500,7 +1500,7 @@ s32 npc_draw_palswap_mode_2(Npc* npc, s32 arg1, s32 arg2, Matrix4f mtx) { npc->palSwapLerpAlpha = 0; npc->palSwapState = 1; } - /* fallthrough */ + // fallthrough case 1: npc->palSwapLerpAlpha += 25600 / npc->unk_30E; if (npc->palSwapLerpAlpha > 25500) { @@ -1531,7 +1531,7 @@ s32 npc_draw_palswap_mode_2(Npc* npc, s32 arg1, s32 arg2, Matrix4f mtx) { npc->palSwapLerpAlpha = 0; npc->palSwapState = 3; } - /* fallthrough */ + // fallthrough case 3: npc->palSwapLerpAlpha += 25600 / npc->unk_312; if (npc->palSwapLerpAlpha > 25500) { @@ -1622,7 +1622,7 @@ s32 npc_draw_palswap_mode_4(Npc* npc, s32 arg1, Matrix4f mtx) { npc->palSwapLerpAlpha = 0; npc->palSwapState = 1; } - /* fallthrough */ + // fallthrough case 1: npc->palSwapLerpAlpha += 25600 / npc->unk_30E; if (npc->palSwapLerpAlpha > 25500) { @@ -1663,7 +1663,7 @@ s32 npc_draw_palswap_mode_4(Npc* npc, s32 arg1, Matrix4f mtx) { npc->palSwapLerpAlpha = 0; npc->palSwapState = 3; } - /* fallthrough */ + // fallthrough case 3: npc->palSwapLerpAlpha += 25600 / npc->unk_312; if (npc->palSwapLerpAlpha > 25500) { @@ -2162,7 +2162,7 @@ void func_8003D624(Npc* npc, s32 foldType, s32 arg2, s32 arg3, s32 arg4, s32 arg //TODO begin split for npc_surfaces void spawn_surface_effects(Npc* npc, SurfaceInteractMode mode) { - PartnerActionStatus* temp = &gPartnerActionStatus; + PartnerStatus* temp = &gPartnerStatus; if ((npc->flags & (NPC_FLAG_TOUCHES_GROUND | NPC_FLAG_INVISIBLE)) == NPC_FLAG_TOUCHES_GROUND) { if (npc->moveSpeed != 0.0f) { diff --git a/src/npc_collision.c b/src/npc_collision.c index a83e6cf7b1..8710aace38 100644 --- a/src/npc_collision.c +++ b/src/npc_collision.c @@ -70,7 +70,7 @@ s32 npc_raycast_down(s32 ignoreFlags, f32* startX, f32* startY, f32* startZ, f32 return colliderID; } -s32 npc_raycast_down_around(s32 ignoreFlags, f32* posX, f32* posY, f32* posZ, f32* hitDepth, f32 yaw, f32 radius) { +b32 npc_raycast_down_around(s32 ignoreFlags, f32* posX, f32* posY, f32* posZ, f32* hitDepth, f32 yaw, f32 radius) { f32 startX; f32 startY; f32 startZ; @@ -490,7 +490,7 @@ s32 npc_test_move_with_slipping(s32 ignoreFlags, f32* x, f32* y, f32* z, f32 len f32 inverseOutCosTheta; s32 raycastHitID; s32 phi_s5; - s32 phi_s2 = -1; + s32 hitResult = NO_COLLIDER; f32 a, b; sin_cos_rad(DEG_TO_RAD(yaw), &outSinTheta, &outCosTheta); @@ -518,7 +518,7 @@ s32 npc_test_move_with_slipping(s32 ignoreFlags, f32* x, f32* y, f32* z, f32 len *x += a + outX; *z += b + outY; NpcHitQueryColliderID = raycastHitID; - phi_s2 = raycastHitID; + hitResult = raycastHitID; } if (phi_s5 == 0) { @@ -526,7 +526,7 @@ s32 npc_test_move_with_slipping(s32 ignoreFlags, f32* x, f32* y, f32* z, f32 len *z += aZ; } - return phi_s2; + return hitResult; } s32 npc_test_move_without_slipping(s32 ignoreFlags, f32* x, f32* y, f32* z, f32 length, f32 yaw, f32 radius) { @@ -566,7 +566,7 @@ s32 npc_test_move_without_slipping(s32 ignoreFlags, f32* x, f32* y, f32* z, f32 return ret; } -s32 npc_test_move_taller_with_slipping(s32 ignoreFlags, f32* x, f32* y, f32* z, f32 length, f32 yaw, f32 height, +b32 npc_test_move_taller_with_slipping(s32 ignoreFlags, f32* x, f32* y, f32* z, f32 length, f32 yaw, f32 height, f32 radius) { f32 xTemp = *x; f32 yTemp = *y + height - 1.0f; @@ -582,14 +582,14 @@ s32 npc_test_move_taller_with_slipping(s32 ignoreFlags, f32* x, f32* y, f32* z, *x = xTemp; *z = zTemp; } else { - ret = 1; + ret = TRUE; *x = xTemp; *z = zTemp; } return ret; } -s32 npc_test_move_simple_with_slipping(s32 ignoreFlags, f32* x, f32* y, f32* z, f32 length, f32 yaw, f32 height, +b32 npc_test_move_simple_with_slipping(s32 ignoreFlags, f32* x, f32* y, f32* z, f32 length, f32 yaw, f32 height, f32 radius) { f32 tempX = *x; f32 tempY = *y + 10.01f; @@ -602,7 +602,7 @@ s32 npc_test_move_simple_with_slipping(s32 ignoreFlags, f32* x, f32* y, f32* z, return hitID >= 0; } -s32 npc_test_move_simple_without_slipping(s32 ignoreFlags, f32* x, f32* y, f32* z, f32 length, f32 yaw, f32 height, +b32 npc_test_move_simple_without_slipping(s32 ignoreFlags, f32* x, f32* y, f32* z, f32 length, f32 yaw, f32 height, f32 radius) { f32 tempX = *x; f32 tempY = *y + 10.01f; diff --git a/src/pulse_stone.c b/src/pulse_stone.c index 38374a7720..5711660d3e 100644 --- a/src/pulse_stone.c +++ b/src/pulse_stone.c @@ -29,13 +29,13 @@ void pulse_stone_notification_update(void); s32 should_cancel_pulse_stone(void) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; s8 actionState = playerStatus->actionState; // could be written more clearly if these two condtions were inverted if (actionState != ACTION_STATE_USE_TWEESTER) { - if (!(partnerActionStatus->partnerActionState == PARTNER_ACTION_USE - && (partnerActionStatus->actingPartner == PARTNER_BOW || partnerActionStatus->actingPartner == PARTNER_PARAKARRY)) + if (!(partnerStatus->partnerActionState == PARTNER_ACTION_USE + && (partnerStatus->actingPartner == PARTNER_BOW || partnerStatus->actingPartner == PARTNER_PARAKARRY)) ) { return FALSE; } diff --git a/src/state_startup.c b/src/state_startup.c index f53f8df053..ce40c6fc02 100644 --- a/src/state_startup.c +++ b/src/state_startup.c @@ -25,7 +25,7 @@ void state_step_startup(void) { gameStatus->entryID = 0; gGameStatusPtr->unk_76 = 0; gGameStatusPtr->disableScripts = 0; - gGameStatusPtr->keepUsingPartnerOnMapChange = 0; + gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; gGameStatusPtr->creditsViewportMode = -1; gGameStatusPtr->demoFlags = 0; gGameStatusPtr->unk_A9 = -1; diff --git a/src/world/action/idle.c b/src/world/action/idle.c index d8ca686dc4..3224678cd4 100644 --- a/src/world/action/idle.c +++ b/src/world/action/idle.c @@ -48,9 +48,7 @@ void action_update_idle(void) { playerStatus->currentStateTime++; if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) { - - playerStatus->flags &= ~(PS_FLAG_ACTION_STATE_CHANGED - | PS_FLAG_ARMS_RAISED | PS_FLAG_AIRBORNE); + playerStatus->flags &= ~(PS_FLAG_ACTION_STATE_CHANGED | PS_FLAG_ARMS_RAISED | PS_FLAG_AIRBORNE); wasMoving = TRUE; playerStatus->actionSubstate = SUBSTATE_IDLE_DEFAULT; playerStatus->currentStateTime = 0; @@ -66,7 +64,7 @@ void action_update_idle(void) { } else if (playerStatus->prevActionState == ACTION_STATE_IDLE) { anim = ANIM_MarioW1_TakeItem; } else { - anim = ANIM_MarioW1_PlaceRecord; + anim = ANIM_MarioW1_CarryIdle; } suggest_player_anim_allow_backward(anim); } diff --git a/src/world/action/misc.c b/src/world/action/misc.c index 0af964bad6..29a08eae2a 100644 --- a/src/world/action/misc.c +++ b/src/world/action/misc.c @@ -1,18 +1,16 @@ #include "common.h" #include "world/actions.h" -#include "world/partner/goombario.h" +#include "world/partner/sushie.h" +#include "world/partner/lakilester.h" BSS f32 D_802B6770_E27C80; -s32 action_update_ride(void) { - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; +void action_update_ride(void) { + PartnerStatus* partnerStatus = &gPartnerStatus; PlayerStatus* playerStatus = &gPlayerStatus; - s32 oldFlags = playerStatus->flags; - + if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) { - playerStatus->flags &= ~( - PS_FLAG_ACTION_STATE_CHANGED | PS_FLAG_ARMS_RAISED | PS_FLAG_AIRBORNE - ); + playerStatus->flags &= ~(PS_FLAG_ACTION_STATE_CHANGED | PS_FLAG_ARMS_RAISED | PS_FLAG_AIRBORNE); playerStatus->actionSubstate = 0; playerStatus->currentStateTime = 0; playerStatus->timeInAir = 0; @@ -22,17 +20,12 @@ s32 action_update_ride(void) { } if (playerStatus->animFlags & PA_FLAG_RIDING_PARTNER) { - if (partnerActionStatus->actingPartner == PARTNER_LAKILESTER) { - return world_goombario_get_trigger_tattle(oldFlags); - } - if (partnerActionStatus->actingPartner == PARTNER_SUSHIE) { - return world_goombario_get_trigger_tattle(oldFlags); + if (partnerStatus->actingPartner == PARTNER_LAKILESTER) { + world_lakilester_sync_player_position(); + } else if (partnerStatus->actingPartner == PARTNER_SUSHIE) { + world_sushie_sync_player_position(); } } - - #ifdef AVOID_UB - return 0; - #endif } void action_update_state_23(void) { @@ -54,8 +47,7 @@ void action_update_state_23(void) { f32 playerOffsetTempVar; if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) { - playerStatus->flags &= ~(PS_FLAG_ACTION_STATE_CHANGED - | PS_FLAG_ARMS_RAISED | PS_FLAG_AIRBORNE); + playerStatus->flags &= ~(PS_FLAG_ACTION_STATE_CHANGED | PS_FLAG_ARMS_RAISED | PS_FLAG_AIRBORNE); playerStatus->actionSubstate = 0; playerStatus->currentStateTime = 0; playerStatus->timeInAir = 0; diff --git a/src/world/action/sneaky_parasol.c b/src/world/action/sneaky_parasol.c index 97a251579d..bbad00be0f 100644 --- a/src/world/action/sneaky_parasol.c +++ b/src/world/action/sneaky_parasol.c @@ -205,7 +205,7 @@ void action_update_parasol(void) { playerStatus->actionSubstate++; // SUBSTATE_DISGUISE_DONE playerStatus->spriteFacingAngle = 180; disguiseNpc = get_npc_by_index(PeachDisguiseNpcIndex); - disguiseNpc->isFacingAway = 1; + disguiseNpc->isFacingAway = TRUE; disguiseNpc->yaw = clamp_angle((cam->currentYaw - playerStatus->spriteFacingAngle) - 90); disguiseNpc->yawCamOffset = disguiseNpc->yaw; } @@ -217,7 +217,7 @@ void action_update_parasol(void) { playerStatus->spriteFacingAngle = 0; playerStatus->actionSubstate++; // SUBSTATE_DISGUISE_DONE disguiseNpc = get_npc_by_index(PeachDisguiseNpcIndex); - disguiseNpc->isFacingAway = 0; + disguiseNpc->isFacingAway = FALSE; disguiseNpc->yaw = clamp_angle((cam->currentYaw - playerStatus->spriteFacingAngle) - 90); disguiseNpc->yawCamOffset = disguiseNpc->yaw; } diff --git a/src/world/action/step_up.c b/src/world/action/step_up.c index 6444ac5c78..586493c77d 100644 --- a/src/world/action/step_up.c +++ b/src/world/action/step_up.c @@ -40,7 +40,7 @@ void action_update_step_up(void) { if (!(playerStatus->animFlags & PA_FLAG_USING_WATT)) { anim = ANIM_Mario1_Walk; } else { - anim = ANIM_MarioW1_Carry; + anim = ANIM_MarioW1_CarryWalk; } suggest_player_anim_allow_backward(anim); } else { diff --git a/src/world/action/walk.c b/src/world/action/walk.c index 9b78cb6fd4..8bd4531326 100644 --- a/src/world/action/walk.c +++ b/src/world/action/walk.c @@ -58,7 +58,7 @@ void action_update_walk(void) { anim = ANIM_Mario1_Walk; } else { - anim = ANIM_MarioW1_Carry; + anim = ANIM_MarioW1_CarryWalk; } suggest_player_anim_allow_backward(anim); } diff --git a/src/world/area_end/common/Credits.inc.c b/src/world/area_end/common/Credits.inc.c index cd63993ef0..4fddc78343 100644 --- a/src/world/area_end/common/Credits.inc.c +++ b/src/world/area_end/common/Credits.inc.c @@ -150,7 +150,7 @@ void N(CharAnim_FadeIn_1)(CreditsLine* line, CreditsChar* chr) { f32 posY = chr->posY; f32 alpha; - alpha = update_lerp(0, 0.0f, 255.0f, chr->fadeInTime, line->appearTime); + alpha = update_lerp(EASING_LINEAR, 0.0f, 255.0f, chr->fadeInTime, line->appearTime); if (alpha > 255.0f) { alpha = 255.0; } diff --git a/src/world/area_flo/flo_13/flo_13_4_npc.c b/src/world/area_flo/flo_13/flo_13_4_npc.c index 475c8bf0f6..c83be61663 100644 --- a/src/world/area_flo/flo_13/flo_13_4_npc.c +++ b/src/world/area_flo/flo_13/flo_13_4_npc.c @@ -31,7 +31,7 @@ API_CALLABLE(N(PlayLakiluluFlightSounds)) { sfx_get_spatialized_sound_params(npc->pos.x, npc->pos.y, npc->pos.z, &volume, &pan, SOUND_PARAM_MORE_QUIET | SOUND_SPACE_FULL); sfx_play_sound_with_params(SOUND_295, volume, pan, - update_lerp(0, 500.0f, 0.0f, script->functionTemp[0], script->functionTemp[1])); + update_lerp(EASING_LINEAR, 500.0f, 0.0f, script->functionTemp[0], script->functionTemp[1])); } script->functionTemp[0]++; @@ -56,7 +56,7 @@ API_CALLABLE(N(PlayLakilesterFlightSounds)) { sfx_get_spatialized_sound_params(npc->pos.x, npc->pos.y, npc->pos.z, &volume, &pan, SOUND_PARAM_MORE_QUIET | SOUND_SPACE_FULL); sfx_play_sound_with_params(SOUND_295, volume, pan, - update_lerp(0, 500.0f, 0.0f, script->functionTemp[0], 80)); + update_lerp(EASING_LINEAR, 500.0f, 0.0f, script->functionTemp[0], 80)); } script->functionTemp[0]++; diff --git a/src/world/area_gv/gv_01/gv_01_1_main.c b/src/world/area_gv/gv_01/gv_01_1_main.c index a917315f6a..68b3381ab7 100644 --- a/src/world/area_gv/gv_01/gv_01_1_main.c +++ b/src/world/area_gv/gv_01/gv_01_1_main.c @@ -283,7 +283,7 @@ API_CALLABLE(N(ChangeStateToTitleScreen)) { gGameStatusPtr->isBattle = FALSE; gGameStatusPtr->unk_76 = 0; gGameStatusPtr->disableScripts = 0; - gGameStatusPtr->keepUsingPartnerOnMapChange = 0; + gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; gOverrideFlags &= ~GLOBAL_OVERRIDES_8; general_heap_create(); clear_render_tasks(); diff --git a/src/world/area_hos/hos_00/hos_00_7_shade_gfx.c b/src/world/area_hos/hos_00/hos_00_7_shade_gfx.c index db5dfb909f..bbbab55cd1 100644 --- a/src/world/area_hos/hos_00/hos_00_7_shade_gfx.c +++ b/src/world/area_hos/hos_00/hos_00_7_shade_gfx.c @@ -1,7 +1,7 @@ #include "hos_00.h" void N(setup_gfx_background_shade)(void) { - s32 alpha = update_lerp(0, 0.0f, 216.0f, gPlayerStatus.position.x - 200.0f, 500); + s32 alpha = update_lerp(EASING_LINEAR, 0.0f, 216.0f, gPlayerStatus.position.x - 200.0f, 500); if (alpha < 0) { alpha = 0; diff --git a/src/world/area_hos/hos_05/hos_05_5_intro.c b/src/world/area_hos/hos_05/hos_05_5_intro.c index 86314bbb62..97b50fb7d0 100644 --- a/src/world/area_hos/hos_05/hos_05_5_intro.c +++ b/src/world/area_hos/hos_05/hos_05_5_intro.c @@ -698,7 +698,7 @@ API_CALLABLE(N(CamPushIn_BowserInhale)) { N(interp_value_with_easing)(INTRO_MATH_EASING_LINEAR, 121.6f, 90.0f, N(CamMoveInhaleTime), 40.0f, &N(BoomLengthInhale)); camera->panActive = TRUE; camera->controlSettings.boomLength = N(BoomLengthInhale); - if ((N(CamMoveInhaleTime) == ((N(CamMoveInhaleTime) / 5) * 5)) && (N(BoomLengthInhale) != 90.0f)) { + if (N(CamMoveInhaleTime) % 5 == 0 && N(BoomLengthInhale) != 90.0f) { f32 temp_f4 = resolve_npc(script, NPC_Bowser_Body)->pos.y - 150.0f; fx_fire_breath( diff --git a/src/world/area_isk/isk_06/isk_06_4_switch.c b/src/world/area_isk/isk_06/isk_06_4_switch.c index 94c3cd89e6..913839f6c2 100644 --- a/src/world/area_isk/isk_06/isk_06_4_switch.c +++ b/src/world/area_isk/isk_06/isk_06_4_switch.c @@ -23,11 +23,11 @@ EvtScript N(EVS_OnTouch_DrainSwitch) = { EVT_END_IF EVT_CALL(DisablePlayerInput, TRUE) EVT_LABEL(5) - EVT_WAIT(1) - EVT_CALL(PartnerCanUseAbility, LVar0) - EVT_IF_EQ(LVar0, TRUE) - EVT_GOTO(5) - EVT_END_IF + EVT_WAIT(1) + EVT_CALL(PartnerCanUseAbility, LVar0) + EVT_IF_EQ(LVar0, TRUE) + EVT_GOTO(5) + EVT_END_IF EVT_CALL(GetNpcPos, NPC_PARTNER, LVar0, LVar1, LVar2) EVT_IF_LT(LVar1, -80) EVT_THREAD diff --git a/src/world/area_isk/isk_12/isk_12_4_switch.c b/src/world/area_isk/isk_12/isk_12_4_switch.c index 1fd2627ab1..7940110f95 100644 --- a/src/world/area_isk/isk_12/isk_12_4_switch.c +++ b/src/world/area_isk/isk_12/isk_12_4_switch.c @@ -8,11 +8,11 @@ EvtScript N(EVS_OnTouch_DrainSwitch) = { EVT_END_IF EVT_CALL(DisablePlayerInput, TRUE) EVT_LABEL(5) - EVT_WAIT(1) - EVT_CALL(PartnerCanUseAbility, LVar0) - EVT_IF_EQ(LVar0, TRUE) - EVT_GOTO(5) - EVT_END_IF + EVT_WAIT(1) + EVT_CALL(PartnerCanUseAbility, LVar0) + EVT_IF_EQ(LVar0, TRUE) + EVT_GOTO(5) + EVT_END_IF EVT_CALL(GetNpcPos, NPC_PARTNER, LVar0, LVar1, LVar2) EVT_IF_LT(LVar1, -470) EVT_THREAD diff --git a/src/world/area_jan/jan_04/jan_04_10_demo.c b/src/world/area_jan/jan_04/jan_04_10_demo.c index 6b2dc9f2ab..bfc522e560 100644 --- a/src/world/area_jan/jan_04/jan_04_10_demo.c +++ b/src/world/area_jan/jan_04/jan_04_10_demo.c @@ -105,7 +105,7 @@ API_CALLABLE(N(SetupDemoScene)) { switch (N(DemoInitState)) { case 0: - rideScriptSrc = partner_get_ride_script(); + rideScriptSrc = partner_get_enter_map_script(); if (rideScriptSrc != NULL) { Evt* newScript; @@ -114,8 +114,8 @@ API_CALLABLE(N(SetupDemoScene)) { newScript->varTable[1] = playerStatus->position.x - 10.0f; newScript->varTable[2] = playerStatus->position.y; newScript->varTable[3] = playerStatus->position.z; - D_8024A290 = newScript; newScript->varTable[12] = 1; + D_8024A290 = newScript; } break; case 1: diff --git a/src/world/area_jan/jan_11/jan_11_3_npc.c b/src/world/area_jan/jan_11/jan_11_3_npc.c index 612d441e20..c69e9fc590 100644 --- a/src/world/area_jan/jan_11/jan_11_3_npc.c +++ b/src/world/area_jan/jan_11/jan_11_3_npc.c @@ -18,7 +18,7 @@ EvtScript N(EVS_YoshiKid_CryForHelp) = { #include "world/common/todo/GetFloorCollider.inc.c" API_CALLABLE(N(IsPartnerWatt)) { - if (gPartnerActionStatus.actingPartner == PARTNER_WATT) { + if (gPartnerStatus.actingPartner == PARTNER_WATT) { script->varTable[9] = TRUE; } else { script->varTable[9] = FALSE; diff --git a/src/world/area_kgr/kgr_02/kgr_02_3_npc.c b/src/world/area_kgr/kgr_02/kgr_02_3_npc.c index 336f353610..4130e2829b 100644 --- a/src/world/area_kgr/kgr_02/kgr_02_3_npc.c +++ b/src/world/area_kgr/kgr_02/kgr_02_3_npc.c @@ -1,7 +1,7 @@ #include "kgr_02.h" API_CALLABLE(N(AwaitPartnerWatt)) { - if (gPartnerActionStatus.actingPartner == PARTNER_WATT) { + if (gPartnerStatus.actingPartner == PARTNER_WATT) { return ApiStatus_DONE2; } else { return ApiStatus_BLOCK; @@ -9,7 +9,7 @@ API_CALLABLE(N(AwaitPartnerWatt)) { } API_CALLABLE(N(AwaitPartnerNotWatt)) { - if (gPartnerActionStatus.actingPartner != PARTNER_WATT) { + if (gPartnerStatus.actingPartner != PARTNER_WATT) { return ApiStatus_DONE2; } else { return ApiStatus_BLOCK; diff --git a/src/world/area_kmr/kmr_00/kmr_00_3_revival.c b/src/world/area_kmr/kmr_00/kmr_00_3_revival.c index 4ee8b684ea..e6b7ec0e74 100644 --- a/src/world/area_kmr/kmr_00/kmr_00_3_revival.c +++ b/src/world/area_kmr/kmr_00/kmr_00_3_revival.c @@ -152,8 +152,7 @@ API_CALLABLE(N(func_802405F0_8AC580)) { npc->pos.y = 100.0f; add_vec2D_polar(&npc->pos.x, &npc->pos.z, 70.0f / DT, npc->moveToPos.x + (script->functionTemp[2] * 51) + 153.0f); npc->pos.y += (-npc->pos.z + -50.0f + 70.0f / DT) * 0.15f; - if ((script->VAR_1 + script->functionTemp[2]) == - (((script->VAR_1 + script->functionTemp[2]) / 13) * 13)) { + if ((script->VAR_1 + script->functionTemp[2]) % 13 == 0) { fx_sparkles(FX_SPARKLES_3, npc->pos.x, npc->pos.y + 10.0f, npc->pos.z, 10.0f); } if (script->VAR_1 > 256) { @@ -167,8 +166,7 @@ API_CALLABLE(N(func_802405F0_8AC580)) { npc->pos.y = 100.0f - (script->VAR_2 * 0.3f); add_vec2D_polar(&npc->pos.x, &npc->pos.z, 70.0f / DT, npc->moveToPos.x + (script->functionTemp[2] * 51) + 153.0f); npc->pos.y += (-npc->pos.z + -50.0f + 70.0f / DT) * 0.15f; - if ((script->VAR_1 + script->functionTemp[2]) == - (((script->VAR_1 + script->functionTemp[2]) / 13) * 13)) { + if ((script->VAR_1 + script->functionTemp[2]) % 13 == 0) { fx_sparkles(FX_SPARKLES_3, npc->pos.x, npc->pos.y + 10.0f, npc->pos.z, 10.0f); } if (script->VAR_2++ > 180) { @@ -188,8 +186,7 @@ API_CALLABLE(N(func_802405F0_8AC580)) { npc->pos.y = 45.999996f; add_vec2D_polar(&npc->pos.x, &npc->pos.z, 70.0f / DT, npc->moveToPos.x + (script->functionTemp[2] * 51) + 153.0f); npc->pos.y += (-npc->pos.z + -50.0f + 70.0f / DT) * 0.15f; - if ((script->VAR_1 + script->functionTemp[2]) == - (((script->VAR_1 + script->functionTemp[2]) / 13) * 13)) { + if ((script->VAR_1 + script->functionTemp[2]) % 13 == 0) { fx_sparkles(FX_SPARKLES_3, npc->pos.x, npc->pos.y + 10.0f, npc->pos.z, 10.0f); } if (npc->moveToPos.y < 0.0f) { diff --git a/src/world/area_kmr/kmr_20/kmr_20_13_records.c b/src/world/area_kmr/kmr_20/kmr_20_13_records.c index 58e1d34905..6a319af399 100644 --- a/src/world/area_kmr/kmr_20/kmr_20_13_records.c +++ b/src/world/area_kmr/kmr_20/kmr_20_13_records.c @@ -146,7 +146,7 @@ void N(appendGfx_records)(void* data) { // fallthrough case RECORDS_STATE_FADING_IN: records->lerpTime++; - records->alpha = update_lerp(0, 32.0f, 255.0f, records->lerpTime, 3); + records->alpha = update_lerp(EASING_LINEAR, 32.0f, 255.0f, records->lerpTime, 3); records->lastAlpha = records->alpha; if (records->lerpTime >= 3) { records->state = RECORDS_STATE_IDLE; @@ -170,7 +170,7 @@ void N(appendGfx_records)(void* data) { // fallthrough case RECORDS_STATE_FADING_OUT: records->lerpTime++; - records->alpha = update_lerp(0, records->lastAlpha, 0.0f, records->lerpTime, 3); + records->alpha = update_lerp(EASING_LINEAR, records->lastAlpha, 0.0f, records->lerpTime, 3); if (records->lerpTime >= 3) { records->state = RECORDS_STATE_DONE; } diff --git a/src/world/area_kpa/kpa_12/kpa_12_3_platforms.c b/src/world/area_kpa/kpa_12/kpa_12_3_platforms.c index 0eca5e5175..1beb11e177 100644 --- a/src/world/area_kpa/kpa_12/kpa_12_3_platforms.c +++ b/src/world/area_kpa/kpa_12/kpa_12_3_platforms.c @@ -29,7 +29,7 @@ API_CALLABLE(N(AddPlatformPushVelocity)) { } API_CALLABLE(N(IsPartnerLakilester)) { - if (gPartnerActionStatus.actingPartner == PARTNER_LAKILESTER) { + if (gPartnerStatus.actingPartner == PARTNER_LAKILESTER) { script->varTable[9] = TRUE; } else { script->varTable[9] = FALSE; diff --git a/src/world/area_kpa/kpa_13/kpa_13_4_platforms.c b/src/world/area_kpa/kpa_13/kpa_13_4_platforms.c index 6d0d6dae11..20aa337b64 100644 --- a/src/world/area_kpa/kpa_13/kpa_13_4_platforms.c +++ b/src/world/area_kpa/kpa_13/kpa_13_4_platforms.c @@ -29,7 +29,7 @@ API_CALLABLE(N(AddPlatformPushVelocity)) { } API_CALLABLE(N(IsPartnerLakilester)) { - if (gPartnerActionStatus.actingPartner == PARTNER_LAKILESTER) { + if (gPartnerStatus.actingPartner == PARTNER_LAKILESTER) { script->varTable[9] = TRUE; } else { script->varTable[9] = FALSE; diff --git a/src/world/area_kpa/kpa_14/kpa_14_2_main.c b/src/world/area_kpa/kpa_14/kpa_14_2_main.c index 404f89a325..50edb4a10f 100644 --- a/src/world/area_kpa/kpa_14/kpa_14_2_main.c +++ b/src/world/area_kpa/kpa_14/kpa_14_2_main.c @@ -4,8 +4,8 @@ #include "world/common/atomic/TexturePan.inc.c" API_CALLABLE(N(GetActingPartner)) { - if (gPartnerActionStatus.partnerActionState != 0) { - script->varTable[9] = gPartnerActionStatus.actingPartner; + if (gPartnerStatus.partnerActionState != 0) { + script->varTable[9] = gPartnerStatus.actingPartner; } else { script->varTable[9] = -1; } diff --git a/src/world/area_kpa/kpa_14/kpa_14_4_platforms.c b/src/world/area_kpa/kpa_14/kpa_14_4_platforms.c index d8ca4e7591..00e6823da3 100644 --- a/src/world/area_kpa/kpa_14/kpa_14_4_platforms.c +++ b/src/world/area_kpa/kpa_14/kpa_14_4_platforms.c @@ -35,7 +35,7 @@ API_CALLABLE(N(AddPlatformPushVelocity)) { } API_CALLABLE(N(IsPartnerLakilester)) { - if (gPartnerActionStatus.actingPartner == PARTNER_LAKILESTER) { + if (gPartnerStatus.actingPartner == PARTNER_LAKILESTER) { script->varTable[9] = TRUE; } else { script->varTable[9] = FALSE; diff --git a/src/world/area_kzn/common/SpinyTromp.inc.c b/src/world/area_kzn/common/SpinyTromp.inc.c index b755a295ea..ad18e3c2d8 100644 --- a/src/world/area_kzn/common/SpinyTromp.inc.c +++ b/src/world/area_kzn/common/SpinyTromp.inc.c @@ -7,8 +7,8 @@ API_CALLABLE(N(SpinyTrompHit)) { } API_CALLABLE(N(SpinyTromp_GetActingPartner)) { - if (gPartnerActionStatus.partnerActionState != PARTNER_ACTION_NONE) { - script->varTable[0] = gPartnerActionStatus.actingPartner; + if (gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE) { + script->varTable[0] = gPartnerStatus.actingPartner; } else { script->varTable[0] = -1; } diff --git a/src/world/area_kzn/kzn_02/kzn_02_2_platforms.c b/src/world/area_kzn/kzn_02/kzn_02_2_platforms.c index eac205f171..ec6c663807 100644 --- a/src/world/area_kzn/kzn_02/kzn_02_2_platforms.c +++ b/src/world/area_kzn/kzn_02/kzn_02_2_platforms.c @@ -28,7 +28,7 @@ API_CALLABLE(N(GetActingPartner)) { Bytecode* args = script->ptrReadPos; s32 outVar = *args++; - evt_set_variable(script, outVar, gPartnerActionStatus.actingPartner); + evt_set_variable(script, outVar, gPartnerStatus.actingPartner); return ApiStatus_DONE2; } diff --git a/src/world/area_kzn/kzn_08/kzn_08_4_extra.c b/src/world/area_kzn/kzn_08/kzn_08_4_extra.c index 582bae9142..88c1144e97 100644 --- a/src/world/area_kzn/kzn_08/kzn_08_4_extra.c +++ b/src/world/area_kzn/kzn_08/kzn_08_4_extra.c @@ -32,7 +32,7 @@ API_CALLABLE(N(func_80243EE0_C75360)) { return ApiStatus_BLOCK; } - if (gPartnerActionStatus.partnerActionState != PARTNER_ACTION_NONE) { + if (gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE) { if (playerData->currentPartner == PARTNER_WATT) { if (!script->functionTemp[1]) { script->functionTemp[1] = TRUE; diff --git a/src/world/area_kzn/kzn_11/kzn_11_2_platforms.c b/src/world/area_kzn/kzn_11/kzn_11_2_platforms.c index c8bdd89735..59d9dd93fe 100644 --- a/src/world/area_kzn/kzn_11/kzn_11_2_platforms.c +++ b/src/world/area_kzn/kzn_11/kzn_11_2_platforms.c @@ -31,7 +31,7 @@ API_CALLABLE(N(GetCurrentFloor)) { } API_CALLABLE(N(IsPartnerLakilester)) { - if (gPartnerActionStatus.actingPartner == PARTNER_LAKILESTER) { + if (gPartnerStatus.actingPartner == PARTNER_LAKILESTER) { script->varTable[9] = TRUE; } else { script->varTable[9] = FALSE; diff --git a/src/world/area_mac/mac_04/npc_toybox_shyguy.inc.c b/src/world/area_mac/mac_04/npc_toybox_shyguy.inc.c index a23e8b22f7..f679c4c068 100644 --- a/src/world/area_mac/mac_04/npc_toybox_shyguy.inc.c +++ b/src/world/area_mac/mac_04/npc_toybox_shyguy.inc.c @@ -1,7 +1,7 @@ #include "world/common/todo/GetFloorCollider.inc.c" API_CALLABLE(N(IsPartnerBow)) { - if (gPartnerActionStatus.actingPartner == PARTNER_BOW) { + if (gPartnerStatus.actingPartner == PARTNER_BOW) { script->varTable[0] = TRUE; } else { script->varTable[0] = FALSE; diff --git a/src/world/area_mim/mim_12/mim_12_5_gate.c b/src/world/area_mim/mim_12/mim_12_5_gate.c index ded9c96239..7a9d1a896f 100644 --- a/src/world/area_mim/mim_12/mim_12_5_gate.c +++ b/src/world/area_mim/mim_12/mim_12_5_gate.c @@ -95,9 +95,9 @@ API_CALLABLE(N(InterpSpriteShadingColor)) { } script->varTable[6]++; - shadingProfile->ambientColor.r = update_lerp(0, script->varTable[3], script->varTable[0], script->varTable[6], 20); - shadingProfile->ambientColor.g = update_lerp(0, script->varTable[4], script->varTable[1], script->varTable[6], 20); - shadingProfile->ambientColor.b = update_lerp(0, script->varTable[5], script->varTable[2], script->varTable[6], 20); + shadingProfile->ambientColor.r = update_lerp(EASING_LINEAR, script->varTable[3], script->varTable[0], script->varTable[6], 20); + shadingProfile->ambientColor.g = update_lerp(EASING_LINEAR, script->varTable[4], script->varTable[1], script->varTable[6], 20); + shadingProfile->ambientColor.b = update_lerp(EASING_LINEAR, script->varTable[5], script->varTable[2], script->varTable[6], 20); if (script->varTable[6] == 20) { if (script->varTable[0] == 255) { @@ -118,7 +118,7 @@ API_CALLABLE(N(MoveNpcAlongArc)) { } if (script->varTable[6] > 0) { - angle = update_lerp(0, script->varTable[3], script->varTable[4], (f32) script->varTable[6], (f32) script->varTable[5]); + angle = update_lerp(EASING_LINEAR, script->varTable[3], script->varTable[4], (f32) script->varTable[6], (f32) script->varTable[5]); sin_cos_deg(angle, &sinAngle, &cosAngle); npc->pos.x = script->varTable[1] + (script->varTable[7] * sinAngle); npc->pos.z = script->varTable[2] + (script->varTable[7] * cosAngle); diff --git a/src/world/area_obk/obk_07/obk_07_6_phonograph.c b/src/world/area_obk/obk_07/obk_07_6_phonograph.c index 19ea6defaa..ae3199c9bb 100644 --- a/src/world/area_obk/obk_07/obk_07_6_phonograph.c +++ b/src/world/area_obk/obk_07/obk_07_6_phonograph.c @@ -886,7 +886,7 @@ EvtScript N(EVS_Inspect_Phonograph) = { EVT_CALL(RemoveKeyItemAt, LVar1) EVT_SET(GB_StoryProgress, STORY_CH3_PLAYED_THE_RECORD) EVT_CALL(EnableModel, MODEL_reco, TRUE) - EVT_CALL(SetPlayerAnimation, ANIM_MarioW1_PlaceRecord) + EVT_CALL(SetPlayerAnimation, ANIM_MarioW1_CarryIdle) EVT_WAIT(15) EVT_CALL(SetPlayerAnimation, ANIM_Mario1_Idle) EVT_WAIT(15) diff --git a/src/world/area_omo/omo_09/omo_09_3_conveyors.c b/src/world/area_omo/omo_09/omo_09_3_conveyors.c index b8c40c914a..dba0b28f4d 100644 --- a/src/world/area_omo/omo_09/omo_09_3_conveyors.c +++ b/src/world/area_omo/omo_09/omo_09_3_conveyors.c @@ -23,7 +23,7 @@ s32 N(ShouldPauseConveyor)(void) { return TRUE; } - if (gPartnerActionStatus.partnerActionState != PARTNER_ACTION_NONE && + if (gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE && (playerData->currentPartner == PARTNER_GOOMBARIO || playerData->currentPartner == PARTNER_SUSHIE)) { return TRUE; @@ -42,7 +42,7 @@ API_CALLABLE(N(WaitWhileConveyorPaused)) { API_CALLABLE(N(AddConveyorPush)) { PlayerStatus* playerStatus = &gPlayerStatus; Npc* partner = get_npc_unsafe(NPC_PARTNER); - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; f32 x, y, z; f32 outLength; f32 hitRx, hitRz; @@ -57,8 +57,8 @@ API_CALLABLE(N(AddConveyorPush)) { } one = 1; - if (partnerActionStatus->actingPartner == PARTNER_BOW) { - if (partnerActionStatus->partnerActionState != PARTNER_ACTION_NONE && playerStatus->alpha1 == 128) { + if (partnerStatus->actingPartner == PARTNER_BOW) { + if (partnerStatus->partnerActionState != PARTNER_ACTION_NONE && playerStatus->alpha1 == 128) { x = playerStatus->position.x; y = playerStatus->position.y; z = playerStatus->position.z; @@ -79,8 +79,8 @@ API_CALLABLE(N(AddConveyorPush)) { } } one = 1; - if (partnerActionStatus->actingPartner != PARTNER_LAKILESTER || - partnerActionStatus->partnerActionState == PARTNER_ACTION_NONE) + if (partnerStatus->actingPartner != PARTNER_LAKILESTER || + partnerStatus->partnerActionState == PARTNER_ACTION_NONE) { for (i = 0; i < ARRAY_COUNT(N(ConveyorColliders)); i++) { if (gCollisionStatus.currentFloor == N(ConveyorColliders)[i] || @@ -91,8 +91,8 @@ API_CALLABLE(N(AddConveyorPush)) { } if (partner->currentFloor == N(ConveyorColliders)[i] && - ((partnerActionStatus->actingPartner != PARTNER_KOOPER) || - (partnerActionStatus->partnerActionState == PARTNER_ACTION_NONE))) + ((partnerStatus->actingPartner != PARTNER_KOOPER) || + (partnerStatus->partnerActionState == PARTNER_ACTION_NONE))) { partner->pos.x += N(ConveyorPushVels)[i][0]; partner->pos.z += N(ConveyorPushVels)[i][one]; // TODO needed to match diff --git a/src/world/area_omo/omo_14/omo_14_3_npc.c b/src/world/area_omo/omo_14/omo_14_3_npc.c index 212c7bfc6e..723e5fd2b1 100644 --- a/src/world/area_omo/omo_14/omo_14_3_npc.c +++ b/src/world/area_omo/omo_14/omo_14_3_npc.c @@ -60,8 +60,8 @@ API_CALLABLE(N(SimpleMoveNPC)) { } API_CALLABLE(N(GetActingPartner)) { - if (gPartnerActionStatus.partnerActionState != PARTNER_ACTION_NONE) { - script->varTable[9] = gPartnerActionStatus.actingPartner; + if (gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE) { + script->varTable[9] = gPartnerStatus.actingPartner; } else { script->varTable[9] = -1; } @@ -69,7 +69,7 @@ API_CALLABLE(N(GetActingPartner)) { } API_CALLABLE(N(IsPartnerWatt)) { - if (gPartnerActionStatus.actingPartner == PARTNER_WATT) { + if (gPartnerStatus.actingPartner == PARTNER_WATT) { script->varTable[1] = TRUE; } else { script->varTable[1] = FALSE; diff --git a/src/world/common/atomic/CreateDarkness.inc.c b/src/world/common/atomic/CreateDarkness.inc.c index 4118da4b77..b35c311c9a 100644 --- a/src/world/common/atomic/CreateDarkness.inc.c +++ b/src/world/common/atomic/CreateDarkness.inc.c @@ -11,7 +11,7 @@ API_CALLABLE(N(DarkRoomUpdate)) { set_screen_overlay_center_worldpos(1, 1, playerStatus->position.x, playerStatus->position.y + 8.0f, playerStatus->position.z); - if (gPartnerActionStatus.partnerActionState != PARTNER_ACTION_NONE) { + if (gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE) { if (playerData->currentPartner == PARTNER_WATT) { if (!script->functionTemp[1]) { script->functionTemp[1] = TRUE; diff --git a/src/world/common/enemy/ai/CleftAI.inc.c b/src/world/common/enemy/ai/CleftAI.inc.c index 43bbb236a4..2d795185bc 100644 --- a/src/world/common/enemy/ai/CleftAI.inc.c +++ b/src/world/common/enemy/ai/CleftAI.inc.c @@ -47,7 +47,7 @@ s32 N(CleftAI_CanSeePlayer)(Evt* script, MobileAISettings* aiSettings, EnemyDete if (fabsf(npc->pos.y - gPlayerStatusPtr->position.y) >= 40.0f) { seesPlayer = FALSE; } - if (gPartnerActionStatus.actingPartner == PARTNER_BOW) { + if (gPartnerStatus.actingPartner == PARTNER_BOW) { seesPlayer = FALSE; } return seesPlayer; diff --git a/src/world/common/enemy/ai/ClubbaNappingAI.inc.c b/src/world/common/enemy/ai/ClubbaNappingAI.inc.c index 83d3a53261..f67441c228 100644 --- a/src/world/common/enemy/ai/ClubbaNappingAI.inc.c +++ b/src/world/common/enemy/ai/ClubbaNappingAI.inc.c @@ -53,14 +53,14 @@ void N(ClubbaNappingAI_Sleep)(Evt* script, MobileAISettings* aiSettings, EnemyDe } if (playerData->currentPartner == PARTNER_KOOPER) { - if (gPartnerActionStatus.partnerActionState == playerData->currentPartner) { + if (gPartnerStatus.partnerActionState == playerData->currentPartner) { shouldWakeUp = TRUE; } } } - if (((playerData->currentPartner == PARTNER_GOOMBARIO) && (gPartnerActionStatus.partnerActionState != PARTNER_ACTION_NONE)) || - ((playerData->currentPartner == PARTNER_BOMBETTE) && (gPartnerActionStatus.partnerActionState == PARTNER_ACTION_BOMBETTE_2))) { + if (((playerData->currentPartner == PARTNER_GOOMBARIO) && (gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE)) || + ((playerData->currentPartner == PARTNER_BOMBETTE) && (gPartnerStatus.partnerActionState == PARTNER_ACTION_BOMBETTE_2))) { posX = npc->pos.x; posZ = npc->pos.z; add_vec2D_polar(&posX, &posZ, 0.0f, npc->yaw); diff --git a/src/world/common/enemy/ai/FireBarAI.inc.c b/src/world/common/enemy/ai/FireBarAI.inc.c index f8829a6b8b..1c1292d4b8 100644 --- a/src/world/common/enemy/ai/FireBarAI.inc.c +++ b/src/world/common/enemy/ai/FireBarAI.inc.c @@ -15,7 +15,7 @@ enum { API_CALLABLE(N(FireBarAI_Main)) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; Bytecode* args = script->ptrReadPos; FireBarAISettings* settings; FireBarData* data; @@ -69,10 +69,10 @@ API_CALLABLE(N(FireBarAI_Main)) { } if (!(data->flags & 2) && !(playerStatus->flags & PS_FLAG_HAZARD_INVINCIBILITY)) { dY = playerStatus->position.y - npc->pos.y; - if (partnerActionStatus->partnerActionState == PARTNER_ACTION_USE) { - if (partnerActionStatus->actingPartner == PARTNER_LAKILESTER) { + if (partnerStatus->partnerActionState == PARTNER_ACTION_USE) { + if (partnerStatus->actingPartner == PARTNER_LAKILESTER) { dY = partnerNpc->pos.y - npc->pos.y; - } else if (partnerActionStatus->actingPartner == PARTNER_PARAKARRY) { + } else if (partnerStatus->actingPartner == PARTNER_PARAKARRY) { dY = (playerStatus->position.y - 10.0f) - npc->pos.y; } } diff --git a/src/world/common/enemy/ai/MagikoopaSpellAI.inc.c b/src/world/common/enemy/ai/MagikoopaSpellAI.inc.c index 49612446d6..8aee0d4b5d 100644 --- a/src/world/common/enemy/ai/MagikoopaSpellAI.inc.c +++ b/src/world/common/enemy/ai/MagikoopaSpellAI.inc.c @@ -26,7 +26,7 @@ s32 N(MagikoopaAI_CanShootSpell)(Evt* script, f32 arg1, f32 arg2, EnemyDetectVol return -1; } - if (gPartnerActionStatus.actingPartner == PARTNER_BOW || gPartnerActionStatus.actingPartner == PARTNER_SUSHIE) { + if (gPartnerStatus.actingPartner == PARTNER_BOW || gPartnerStatus.actingPartner == PARTNER_SUSHIE) { return -1; } @@ -71,7 +71,7 @@ API_CALLABLE(N(MagikoopaAI_SpellMain)) { npc1->pos.z = NPC_DISPOSE_POS_Z; enemy->varTable[0] = 0; script->functionTemp[0] = 1; - /* fallthrough */ + // fallthrough case 1: if (enemy->varTable[0] == 1) { s32 duration; @@ -118,7 +118,7 @@ API_CALLABLE(N(MagikoopaAI_SpellMain)) { npc1->pos.y += npc1->jumpVelocity; break; } - /* fallthrough */ + // fallthrough case 3: npc1->jumpVelocity = 0.0f; npc1->moveSpeed = 0.0f; diff --git a/src/world/common/enemy/ai/MeleeHitbox.inc.c b/src/world/common/enemy/ai/MeleeHitbox.inc.c index b10b1f235a..6784db1b51 100644 --- a/src/world/common/enemy/ai/MeleeHitbox.inc.c +++ b/src/world/common/enemy/ai/MeleeHitbox.inc.c @@ -86,11 +86,11 @@ s32 N(MeleeHitbox_CanSeePlayer)(Evt* script) { ret = FALSE; } - if (gPartnerActionStatus.actingPartner == PARTNER_BOW) { + if (gPartnerStatus.actingPartner == PARTNER_BOW) { ret = FALSE; } - if (gPartnerActionStatus.actingPartner == PARTNER_SUSHIE) { + if (gPartnerStatus.actingPartner == PARTNER_SUSHIE) { ret = FALSE; } diff --git a/src/world/common/enemy/ai/MontyMoleAI.inc.c b/src/world/common/enemy/ai/MontyMoleAI.inc.c index 09b8e03ee4..b7e656e887 100644 --- a/src/world/common/enemy/ai/MontyMoleAI.inc.c +++ b/src/world/common/enemy/ai/MontyMoleAI.inc.c @@ -57,7 +57,7 @@ static s32 N(MontyMoleAI_CanAttack)(Evt* script, EnemyDetectVolume* territory, f retVal = FALSE; } // check for bow hiding - if (gPartnerActionStatus.actingPartner == PARTNER_BOW) { + if (gPartnerStatus.actingPartner == PARTNER_BOW) { retVal = FALSE; } return retVal; diff --git a/src/world/common/enemy/ai/PiranhaPlantAI.inc.c b/src/world/common/enemy/ai/PiranhaPlantAI.inc.c index 51f599b3b2..2bbcf2d24e 100644 --- a/src/world/common/enemy/ai/PiranhaPlantAI.inc.c +++ b/src/world/common/enemy/ai/PiranhaPlantAI.inc.c @@ -125,7 +125,7 @@ void N(PiranhaPlantAI_10)(Evt* script, MobileAISettings* aiSettings, EnemyDetect sp20 = gPlayerStatusPtr->position.x; sp24 = gPlayerStatusPtr->position.y + 18.0; sp28 = gPlayerStatusPtr->position.z; - if (npc_test_move_simple_with_slipping(npc->collisionChannel, &sp20, &sp24, &sp28, moveSpeed, yaw2, npc->collisionHeight, npc->collisionRadius) != 0) { + if (npc_test_move_simple_with_slipping(npc->collisionChannel, &sp20, &sp24, &sp28, moveSpeed, yaw2, npc->collisionHeight, npc->collisionRadius)) { sp20 = gPlayerStatusPtr->position.x; sp24 = gPlayerStatusPtr->position.y + 45.0; sp28 = gPlayerStatusPtr->position.z; @@ -154,7 +154,7 @@ void N(PiranhaPlantAI_10)(Evt* script, MobileAISettings* aiSettings, EnemyDetect sp20 = gPlayerStatusPtr->position.x; sp24 = gPlayerStatusPtr->position.y + 18.0; sp28 = gPlayerStatusPtr->position.z; - if (npc_test_move_simple_with_slipping(npc->collisionChannel, &sp20, &sp24, &sp28, moveSpeed, yaw2, npc->collisionHeight, npc->collisionRadius) != 0) { + if (npc_test_move_simple_with_slipping(npc->collisionChannel, &sp20, &sp24, &sp28, moveSpeed, yaw2, npc->collisionHeight, npc->collisionRadius)) { posRadius = dist2D(gPlayerStatusPtr->position.x, gPlayerStatusPtr->position.z, sp20, sp28); npc->pos.x = gPlayerStatusPtr->position.x; npc->pos.z = gPlayerStatusPtr->position.z; diff --git a/src/world/common/enemy/ai/ProjectileHitbox.inc.c b/src/world/common/enemy/ai/ProjectileHitbox.inc.c index 6d8c50e544..b754eb846f 100644 --- a/src/world/common/enemy/ai/ProjectileHitbox.inc.c +++ b/src/world/common/enemy/ai/ProjectileHitbox.inc.c @@ -28,10 +28,10 @@ s32 N(ProjectileHitbox_GetUsableProjectileID)(Evt* script) { if (fabsf(deltaAngle) > 75.0 || (2.0 * npc->collisionHeight <= fabsf(npc->pos.y - gPlayerStatusPtr->position.y))) { return -1; } - if (gPartnerActionStatus.actingPartner == PARTNER_BOW) { + if (gPartnerStatus.actingPartner == PARTNER_BOW) { return -1; } - if (gPartnerActionStatus.actingPartner == PARTNER_SUSHIE) { + if (gPartnerStatus.actingPartner == PARTNER_SUSHIE) { return -1; } diff --git a/src/world/common/enemy/ai/SentinelAI.inc.c b/src/world/common/enemy/ai/SentinelAI.inc.c index 838b3aea55..abdd642693 100644 --- a/src/world/common/enemy/ai/SentinelAI.inc.c +++ b/src/world/common/enemy/ai/SentinelAI.inc.c @@ -143,7 +143,7 @@ void N(SentinelAI_Descend)(Evt* script, MobileAISettings* aiSettings, EnemyDetec } else { npc->rotation.y = 0.0f; npc->flags &= ~NPC_FLAG_200000; - if (gPartnerActionStatus.actingPartner != PARTNER_BOW) { + if (gPartnerStatus.actingPartner != PARTNER_BOW) { disable_player_input(); partner_disable_input(); npc->duration = 0; @@ -208,7 +208,7 @@ void N(SentinelAI_GrabPlayer)(Evt* script, MobileAISettings* aiSettings, EnemyDe npc->duration++; if (npc->duration >= 3) { - if (gPartnerActionStatus.actingPartner != PARTNER_BOW) { + if (gPartnerStatus.actingPartner != PARTNER_BOW) { npc->duration = 0; script->AI_TEMP_STATE = AI_STATE_SENTINEL_CAUGHT_PLAYER; } else { diff --git a/src/world/common/enemy/ai/SwooperAI.inc.c b/src/world/common/enemy/ai/SwooperAI.inc.c index 6aeb1345d6..68319f5af9 100644 --- a/src/world/common/enemy/ai/SwooperAI.inc.c +++ b/src/world/common/enemy/ai/SwooperAI.inc.c @@ -85,7 +85,7 @@ API_CALLABLE(N(SwooperAI_Main)) { x = npc->pos.x; y = npc->pos.y; z = npc->pos.z; - if (npc_test_move_simple_with_slipping(npc->collisionChannel, &x, &y, &z, npc->moveSpeed, npc->yaw, npc->collisionHeight, npc->collisionRadius) != 0) { + if (npc_test_move_simple_with_slipping(npc->collisionChannel, &x, &y, &z, npc->moveSpeed, npc->yaw, npc->collisionHeight, npc->collisionRadius)) { npc->moveSpeed = 0.0f; } npc->yaw = atan2(npc->pos.x, npc->pos.z, playerStatus->position.x, playerStatus->position.z); diff --git a/src/world/common/entity/SuperBlock.inc.c b/src/world/common/entity/SuperBlock.inc.c index 36cab98d79..f74118e4bf 100644 --- a/src/world/common/entity/SuperBlock.inc.c +++ b/src/world/common/entity/SuperBlock.inc.c @@ -429,7 +429,7 @@ API_CALLABLE(N(SuperBlock_PartnerSparkles4)) { API_CALLABLE(N(SuperBlock_WaitForPlayerToLand)) { script->varTable[0] = FALSE; - if ((gPartnerActionStatus.partnerActionState != PARTNER_ACTION_NONE) && (gPartnerActionStatus.actingPartner == PARTNER_BOMBETTE)) { + if ((gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE) && (gPartnerStatus.actingPartner == PARTNER_BOMBETTE)) { script->varTable[0] = TRUE; } return ApiStatus_DONE2; diff --git a/src/world/common/todo/StarSpiritEffectFunc.inc.c b/src/world/common/todo/StarSpiritEffectFunc.inc.c index 2909c8cf48..635440664b 100644 --- a/src/world/common/todo/StarSpiritEffectFunc.inc.c +++ b/src/world/common/todo/StarSpiritEffectFunc.inc.c @@ -63,9 +63,9 @@ API_CALLABLE(N(StarSpiritEffectFunc3)) { switch (ptr->unk_44) { case 0: - ptr->unk_04 = update_lerp(5, ptr->unk_10, ptr->unk_1C, ptr->unk_46, ptr->unk_3C); - ptr->unk_00 = update_lerp(0, ptr->unk_0C, ptr->unk_18, ptr->unk_46, ptr->unk_3C); - ptr->unk_08 = update_lerp(0, ptr->unk_14, ptr->unk_20, ptr->unk_46, ptr->unk_3C); + ptr->unk_04 = update_lerp(EASING_CUBIC_OUT, ptr->unk_10, ptr->unk_1C, ptr->unk_46, ptr->unk_3C); + ptr->unk_00 = update_lerp(EASING_LINEAR, ptr->unk_0C, ptr->unk_18, ptr->unk_46, ptr->unk_3C); + ptr->unk_08 = update_lerp(EASING_LINEAR, ptr->unk_14, ptr->unk_20, ptr->unk_46, ptr->unk_3C); ptr->unk_50->data.starSpiritsEnergy->unk_08 = ptr->unk_00; ptr->unk_50->data.starSpiritsEnergy->unk_0C = ptr->unk_04; ptr->unk_50->data.starSpiritsEnergy->unk_10 = ptr->unk_08; @@ -99,7 +99,7 @@ API_CALLABLE(N(StarSpiritEffectFunc3)) { } break; case 3: - ptr->unk_30 = update_lerp(0, 36.0f, 19.0f, ptr->unk_46, 120); + ptr->unk_30 = update_lerp(EASING_LINEAR, 36.0f, 19.0f, ptr->unk_46, 120); ptr->unk_46++; if (ptr->unk_46 >= 120) { ptr->unk_4C = 0; @@ -117,8 +117,8 @@ API_CALLABLE(N(StarSpiritEffectFunc3)) { switch (ptr->unk_4A) { case 1: - ptr->unk_2C = update_lerp(4, ptr->unk_34, 1440.0f, ptr->unk_4C, 120); - ptr->unk_04 = update_lerp(0xA, ptr->unk_1C, ptr->unk_24, ptr->unk_4C, 120); + ptr->unk_2C = update_lerp(EASING_QUADRATIC_OUT, ptr->unk_34, 1440.0f, ptr->unk_4C, 120); + ptr->unk_04 = update_lerp(EASING_COS_IN_OUT, ptr->unk_1C, ptr->unk_24, ptr->unk_4C, 120); ptr->unk_4C++; if (ptr->unk_4C >= 120) { ptr->unk_4C = 270; diff --git a/src/world/common/todo/WaitForPlayerToLand.inc.c b/src/world/common/todo/WaitForPlayerToLand.inc.c index 9d99c3ae92..5cf4f6250c 100644 --- a/src/world/common/todo/WaitForPlayerToLand.inc.c +++ b/src/world/common/todo/WaitForPlayerToLand.inc.c @@ -3,7 +3,7 @@ API_CALLABLE(N(WaitForPlayerToLand)) { script->varTable[0] = 0; - if ((gPartnerActionStatus.partnerActionState != PARTNER_ACTION_NONE) && (gPartnerActionStatus.actingPartner == PARTNER_BOMBETTE)) { + if ((gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE) && (gPartnerStatus.actingPartner == PARTNER_BOMBETTE)) { script->varTable[0] = 1; } return ApiStatus_DONE2; diff --git a/src/world/dead/area_flo/flo_13/flo_13_4_npc.c b/src/world/dead/area_flo/flo_13/flo_13_4_npc.c index b4fc383559..334bca2b4f 100644 --- a/src/world/dead/area_flo/flo_13/flo_13_4_npc.c +++ b/src/world/dead/area_flo/flo_13/flo_13_4_npc.c @@ -32,7 +32,7 @@ API_CALLABLE(N(PlayLakiluluFlightSounds)) { sfx_get_spatialized_sound_params(npc->pos.x, npc->pos.y, npc->pos.z, &volume, &pan, SOUND_PARAM_MORE_QUIET | SOUND_SPACE_FULL); sfx_play_sound_with_params(SOUND_295, volume, pan, - update_lerp(0, 500.0f, 0.0f, script->functionTemp[0], script->functionTemp[1])); + update_lerp(EASING_LINEAR, 500.0f, 0.0f, script->functionTemp[0], script->functionTemp[1])); } script->functionTemp[0]++; @@ -57,7 +57,7 @@ API_CALLABLE(N(PlayLakilesterFlightSounds)) { sfx_get_spatialized_sound_params(npc->pos.x, npc->pos.y, npc->pos.z, &volume, &pan, SOUND_PARAM_MORE_QUIET | SOUND_SPACE_FULL); sfx_play_sound_with_params(SOUND_295, volume, pan, - update_lerp(0, 500.0f, 0.0f, script->functionTemp[0], 80)); + update_lerp(EASING_LINEAR, 500.0f, 0.0f, script->functionTemp[0], 80)); } script->functionTemp[0]++; diff --git a/src/world/dead/area_kzn/kzn_11/kzn_11_2_platforms.c b/src/world/dead/area_kzn/kzn_11/kzn_11_2_platforms.c index c8bdd89735..59d9dd93fe 100644 --- a/src/world/dead/area_kzn/kzn_11/kzn_11_2_platforms.c +++ b/src/world/dead/area_kzn/kzn_11/kzn_11_2_platforms.c @@ -31,7 +31,7 @@ API_CALLABLE(N(GetCurrentFloor)) { } API_CALLABLE(N(IsPartnerLakilester)) { - if (gPartnerActionStatus.actingPartner == PARTNER_LAKILESTER) { + if (gPartnerStatus.actingPartner == PARTNER_LAKILESTER) { script->varTable[9] = TRUE; } else { script->varTable[9] = FALSE; diff --git a/src/world/partner/bombette.c b/src/world/partner/bombette.c index d3f13fab6e..ac40ef7f57 100644 --- a/src/world/partner/bombette.c +++ b/src/world/partner/bombette.c @@ -192,7 +192,7 @@ void N(try_cancel_tweester)(Npc* npc) { } s32 N(can_use_ability)(Npc* npc) { - if (gPartnerActionStatus.partnerActionState != PARTNER_ACTION_NONE) { + if (gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE) { N(TriggeredEarlyDetonation) = TRUE; return FALSE; } @@ -200,13 +200,13 @@ s32 N(can_use_ability)(Npc* npc) { } s32 N(can_player_pause)(Npc* npc) { - return gPartnerActionStatus.partnerActionState == PARTNER_ACTION_NONE; + return gPartnerStatus.partnerActionState == PARTNER_ACTION_NONE; } API_CALLABLE(N(UseAbility)) { PlayerStatus* playerStatus = &gPlayerStatus; CollisionStatus* collisionStatus = &gCollisionStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; Camera* camera = &gCameras[CAM_DEFAULT]; Npc* npc = script->owner2.npc; u16 temp_ret; @@ -250,8 +250,8 @@ API_CALLABLE(N(UseAbility)) { N(MaintainPosAfterBlast) = FALSE; N(TriggeredEarlyDetonation) = FALSE; npc->flags &= ~(NPC_FLAG_JUMPING | NPC_FLAG_GRAVITY | NPC_FLAG_IGNORE_WORLD_COLLISION | NPC_FLAG_8); - partnerActionStatus->partnerActionState = PARTNER_ACTION_USE; - partnerActionStatus->actingPartner = PARTNER_BOMBETTE; + partnerStatus->partnerActionState = PARTNER_ACTION_USE; + partnerStatus->actingPartner = PARTNER_BOMBETTE; N(PlayerWasFacingLeft) = partner_force_player_flip_done(); enable_npc_blur(npc); npc->duration = 4; @@ -430,7 +430,7 @@ API_CALLABLE(N(UseAbility)) { collisionStatus->bombetteExplosionPos.z = npc->pos.z; N(blast_affect_entities)(npc); N(IsBlasting) = TRUE; - partnerActionStatus->partnerActionState = PARTNER_ACTION_BOMBETTE_2; + partnerStatus->partnerActionState = PARTNER_ACTION_BOMBETTE_2; script->functionTemp[1] = 3; script->USE_STATE++; break; @@ -439,7 +439,7 @@ API_CALLABLE(N(UseAbility)) { script->functionTemp[1]--; break; } - partnerActionStatus->partnerActionState = PARTNER_ACTION_BOMBETTE_3; + partnerStatus->partnerActionState = PARTNER_ACTION_BOMBETTE_3; N(IsBlasting) = FALSE; npc->jumpVelocity = ((playerStatus->position.y - npc->pos.y) / 20.0f) + 30.0; npc->moveSpeed = 0.8f; @@ -513,8 +513,8 @@ API_CALLABLE(N(UseAbility)) { N(LockingPlayerInput) = FALSE; enable_player_input(); } - partnerActionStatus->partnerActionState = ACTION_STATE_IDLE; - partnerActionStatus->actingPartner = PARTNER_NONE; + partnerStatus->partnerActionState = ACTION_STATE_IDLE; + partnerStatus->actingPartner = PARTNER_NONE; npc->jumpVelocity = 0.0f; N(IsBlasting) = FALSE; N(TriggeredEarlyDetonation) = FALSE; @@ -534,8 +534,8 @@ API_CALLABLE(N(UseAbility)) { N(LockingPlayerInput) = FALSE; enable_player_input(); } - partnerActionStatus->partnerActionState = PARTNER_ACTION_NONE; - partnerActionStatus->actingPartner = PARTNER_NONE; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; + partnerStatus->actingPartner = PARTNER_NONE; npc->jumpVelocity = 0.0f; npc->pos.y = playerStatus->position.y; npc->rotation.x = 0.0f; @@ -643,9 +643,9 @@ s32 N(test_first_strike)(Npc* bombette, Npc* enemy) { void N(pre_battle)(Npc* bombette) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* bombetteActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; - if (bombetteActionStatus->partnerActionState != PARTNER_ACTION_NONE) { + if (partnerStatus->partnerActionState != PARTNER_ACTION_NONE) { if (N(LockingPlayerInput)) { enable_player_input(); } @@ -658,8 +658,8 @@ void N(pre_battle)(Npc* bombette) { set_action_state(ACTION_STATE_IDLE); partner_clear_player_tracking(bombette); - bombetteActionStatus->partnerActionState = PARTNER_ACTION_NONE; - bombetteActionStatus->actingPartner = 0; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; + partnerStatus->actingPartner = 0; bombette->pos.x = playerStatus->position.x; bombette->pos.y = playerStatus->position.y; diff --git a/src/world/partner/bow.c b/src/world/partner/bow.c index 8525106f52..9e81f50a8c 100644 --- a/src/world/partner/bow.c +++ b/src/world/partner/bow.c @@ -53,7 +53,7 @@ API_CALLABLE(N(Update)) { if (isInitialCall) { partner_flying_enable(bow, 1); - mem_clear(N(TweesterPhysicsPtr), sizeof(*N(TweesterPhysicsPtr))); + mem_clear(N(TweesterPhysicsPtr), sizeof(TweesterPhysics)); TweesterTouchingPartner = NULL; } @@ -164,7 +164,7 @@ s32 N(check_for_treadmill_overlaps)(void) { API_CALLABLE(N(UseAbility)) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; CollisionStatus* collisionStatus = &gCollisionStatus; Npc* bow = script->owner2.npc; f32 stickInputMag; @@ -198,7 +198,7 @@ API_CALLABLE(N(UseAbility)) { switch (script->USE_STATE) { case OUTTA_SIGHT_INIT: - if (playerStatus->inputDisabledCount) { + if (playerStatus->inputDisabledCount != 0) { return ApiStatus_DONE2; } @@ -249,8 +249,8 @@ API_CALLABLE(N(UseAbility)) { N(IsHiding) = TRUE; bow->flags &= ~(NPC_FLAG_JUMPING | NPC_FLAG_GRAVITY); - partnerActionStatus->partnerActionState = 1; - partnerActionStatus->actingPartner = 9; + partnerStatus->partnerActionState = 1; + partnerStatus->actingPartner = 9; playerStatus->flags |= PS_FLAG_HAZARD_INVINCIBILITY; partner_force_player_flip_done(); bow->moveToPos.x = playerStatus->position.x; @@ -259,8 +259,7 @@ API_CALLABLE(N(UseAbility)) { bow->currentAnim = ANIM_WorldBow_Walk; bow->yaw = playerStatus->targetYaw; add_vec2D_polar(&bow->moveToPos.x, &bow->moveToPos.z, -2.0f, gCameras[gCurrentCameraID].currentYaw); - add_vec2D_polar(&bow->moveToPos.x, &bow->moveToPos.z, - playerStatus->colliderDiameter * 0.5f, bow->yaw); + add_vec2D_polar(&bow->moveToPos.x, &bow->moveToPos.z, playerStatus->colliderDiameter * 0.5f, bow->yaw); bow->duration = 5; bow->yaw = atan2(bow->pos.x, bow->pos.z, playerStatus->position.x, playerStatus->position.z); set_action_state(ACTION_STATE_RIDE); @@ -289,7 +288,6 @@ API_CALLABLE(N(UseAbility)) { } break; } - N(end_outta_sight_cleanup)(bow); return ApiStatus_DONE2; @@ -311,7 +309,6 @@ API_CALLABLE(N(UseAbility)) { bow->pos.z = playerStatus->position.z - N(OuttaSightPosZ); break; } - N(end_outta_sight_cleanup)(bow); return ApiStatus_DONE2; @@ -325,10 +322,10 @@ API_CALLABLE(N(UseAbility)) { bow->pos.y = playerStatus->position.y - N(OuttaSightPosY); bow->pos.z = playerStatus->position.z - N(OuttaSightPosZ); - stickInputMag = dist2D(0.0f, 0.0f, partnerActionStatus->stickX, partnerActionStatus->stickY); + stickInputMag = dist2D(0.0f, 0.0f, partnerStatus->stickX, partnerStatus->stickY); if ((collisionStatus->currentFloor <= NO_COLLIDER) || stickInputMag > 10.0f - || partnerActionStatus->pressedButtons & (BUTTON_B | BUTTON_C_DOWN) + || partnerStatus->pressedButtons & (BUTTON_B | BUTTON_C_DOWN) || playerStatus->flags & PS_FLAG_HIT_FIRE ) { // prevent exiting from the ground while underneath a wall @@ -366,13 +363,13 @@ EvtScript EVS_WorldBow_UseAbility = { void N(end_outta_sight_cleanup)(Npc* bow) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; s32 actionState; playerStatus->alpha1 = 255; func_8003D624(bow, FOLD_TYPE_NONE, 0, 0, 0, 0, 0); bow->renderMode = RENDER_MODE_SURFACE_XLU_LAYER1; - get_shadow_by_index(bow->shadowIndex)->alpha = playerStatus->alpha1 >> 1; + get_shadow_by_index(bow->shadowIndex)->alpha = playerStatus->alpha1 / 2; if (N(LockingPlayerInput)) { enable_player_input(); @@ -388,8 +385,8 @@ void N(end_outta_sight_cleanup)(Npc* bow) { } set_action_state(actionState); - partnerActionStatus->partnerActionState = 0; - partnerActionStatus->actingPartner = 0; + partnerStatus->partnerActionState = 0; + partnerStatus->actingPartner = 0; playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED; partner_clear_player_tracking(bow); N(IsHiding) = FALSE; @@ -420,14 +417,14 @@ EvtScript EVS_WorldBow_PutAway = { }; void N(pre_battle)(Npc* bow) { - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; if (N(IsHiding)) { enable_player_input(); set_action_state(ACTION_STATE_IDLE); partner_clear_player_tracking(bow); - partnerActionStatus->partnerActionState = PARTNER_ACTION_NONE; - partnerActionStatus->actingPartner = PARTNER_NONE; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; + partnerStatus->actingPartner = PARTNER_NONE; N(IsHiding) = FALSE; bow->flags &= ~NPC_FLAG_INVISIBLE; } diff --git a/src/world/partner/goombario.c b/src/world/partner/goombario.c index 75aa886185..e7079a3d18 100644 --- a/src/world/partner/goombario.c +++ b/src/world/partner/goombario.c @@ -202,10 +202,10 @@ EvtScript EVS_WorldGoombario_Update = { }; s32 N(can_pause)(Npc* goombario) { - PartnerActionStatus* goombarioActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; s32 new_var; - if (goombarioActionStatus->partnerActionState != PARTNER_ACTION_NONE) { + if (partnerStatus->partnerActionState != PARTNER_ACTION_NONE) { return FALSE; } @@ -283,7 +283,7 @@ API_CALLABLE(N(SelectTattleMsg)) { playerStatus->flags &= ~PS_FLAG_HAS_CONVERSATION_NPC; goombario->currentAnim = ANIM_WorldGoombario_Idle; goombario->yaw = clamp_angle(gCameras[CAM_DEFAULT].currentYaw + playerStatus->spriteFacingAngle - 90.0f); - gPartnerActionStatus.partnerActionState = PARTNER_ACTION_USE; + gPartnerStatus.partnerActionState = PARTNER_ACTION_USE; close_status_menu(); if (N(HadSpeechPrompt)) { script->VAR_MSG = 0; @@ -434,7 +434,7 @@ API_CALLABLE(N(SelectTattleMsg)) { } API_CALLABLE(N(TattleEnd)) { - PartnerActionStatus* goombarioActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; set_time_freeze_mode(TIME_FREEZE_NORMAL); @@ -443,8 +443,8 @@ API_CALLABLE(N(TattleEnd)) { enable_player_input(); } - goombarioActionStatus->partnerActionState = PARTNER_ACTION_NONE; - goombarioActionStatus->actingPartner = PARTNER_NONE; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; + partnerStatus->actingPartner = PARTNER_NONE; return ApiStatus_DONE2; } @@ -491,17 +491,17 @@ EvtScript EVS_WorldGoombario_PutAway = { }; void N(pre_battle)(Npc* goombario) { - PartnerActionStatus* goombarioActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; - if (goombarioActionStatus->partnerActionState != PARTNER_ACTION_NONE) { + if (partnerStatus->partnerActionState != PARTNER_ACTION_NONE) { set_time_freeze_mode(TIME_FREEZE_NORMAL); enable_player_input(); cancel_current_message(); partner_clear_player_tracking(goombario); - goombarioActionStatus->partnerActionState = PARTNER_ACTION_NONE; - goombarioActionStatus->actingPartner = PARTNER_NONE; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; + partnerStatus->actingPartner = PARTNER_NONE; disable_npc_blur(goombario); } - goombarioActionStatus->actingPartner = PARTNER_GOOMBARIO; + partnerStatus->actingPartner = PARTNER_GOOMBARIO; } diff --git a/src/world/partner/goombario.h b/src/world/partner/goombario.h index 5ce2277b43..51f377edc5 100644 --- a/src/world/partner/goombario.h +++ b/src/world/partner/goombario.h @@ -7,7 +7,6 @@ void world_goombario_init(Npc* partner); s32 world_goombario_can_pause(Npc* partner); void world_goombario_pre_battle(Npc* partner); -s32 world_goombario_get_trigger_tattle(s32 arg0); extern EvtScript EVS_WorldGoombario_TakeOut; extern EvtScript EVS_WorldGoombario_Update; diff --git a/src/world/partner/kooper.c b/src/world/partner/kooper.c index aef25efe25..c1212fcbb2 100644 --- a/src/world/partner/kooper.c +++ b/src/world/partner/kooper.c @@ -202,7 +202,7 @@ API_CALLABLE(N(UseAbility)) { EncounterStatus* currentEncounter = &gCurrentEncounter; PlayerStatus* playerStatus = &gPlayerStatus; Npc* kooper = script->owner2.npc; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; CollisionStatus* collisionStatus = &gCollisionStatus; f32 posX, posY, posZ, hitLength; f32 testLength; @@ -243,9 +243,9 @@ API_CALLABLE(N(UseAbility)) { } else { return ApiStatus_DONE2; } - } else if (partnerActionStatus->partnerActionState == PARTNER_ACTION_NONE) { - partnerActionStatus->partnerActionState = PARTNER_ACTION_KOOPER_GATHER; - partnerActionStatus->actingPartner = PARTNER_KOOPER; + } else if (partnerStatus->partnerActionState == PARTNER_ACTION_NONE) { + partnerStatus->partnerActionState = PARTNER_ACTION_KOOPER_GATHER; + partnerStatus->actingPartner = PARTNER_KOOPER; script->USE_STATE = SHELL_TOSS_STATE_HOLD; kooper->currentAnim = ANIM_WorldKooper_SpinShell; N(ShellTossHoldTime) = 30; @@ -268,8 +268,8 @@ API_CALLABLE(N(UseAbility)) { N(HasItem) = FALSE; kooper->flags &= ~(NPC_FLAG_GRAVITY | NPC_FLAG_JUMPING | NPC_FLAG_8); kooper->flags |= (NPC_FLAG_IGNORE_PLAYER_COLLISION | NPC_FLAG_IGNORE_WORLD_COLLISION); - partnerActionStatus->actingPartner = PARTNER_KOOPER; - partnerActionStatus->partnerActionState = PARTNER_ACTION_KOOPER_GATHER; + partnerStatus->actingPartner = PARTNER_KOOPER; + partnerStatus->partnerActionState = PARTNER_ACTION_KOOPER_GATHER; N(PlayerWasFacingLeft) = partner_force_player_flip_done(); enable_npc_blur(kooper); kooper->duration = 4; @@ -368,8 +368,8 @@ API_CALLABLE(N(UseAbility)) { if (!(kooper->jumpVelocity > 0.0f) && (playerStatus->position.y < kooper->moveToPos.z)) { N(D_802BEC5C) = 0; kooper->flags &= ~NPC_FLAG_IGNORE_PLAYER_COLLISION; - partnerActionStatus->actingPartner = PARTNER_KOOPER; - partnerActionStatus->partnerActionState = PARTNER_ACTION_KOOPER_TOSS; + partnerStatus->actingPartner = PARTNER_KOOPER; + partnerStatus->partnerActionState = PARTNER_ACTION_KOOPER_TOSS; kooper->rotation.z = 0.0f; kooper->planarFlyDist = 0.0f; kooper->moveSpeed = 8.0f; @@ -615,8 +615,8 @@ API_CALLABLE(N(UseAbility)) { ShellTossHitboxState = SHELL_TOSS_HITBOX_DISABLED; kooper->flags |= NPC_FLAG_IGNORE_PLAYER_COLLISION; kooper->flags &= ~(NPC_FLAG_JUMPING | NPC_FLAG_IGNORE_WORLD_COLLISION); - partnerActionStatus->actingPartner = PARTNER_NONE; - partnerActionStatus->partnerActionState = PARTNER_ACTION_NONE; + partnerStatus->actingPartner = PARTNER_NONE; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; kooper->jumpVelocity = 0.0f; kooper->collisionHeight = 24; kooper->currentAnim = ANIM_WorldKooper_Walk; @@ -721,11 +721,11 @@ s32 N(test_first_strike)(Npc* kooper, Npc* enemy) { void N(pre_battle)(Npc* kooper) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* kooperActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; N(TriggeredBattle) = FALSE; - if (kooperActionStatus->partnerActionState != PARTNER_ACTION_NONE) { - if (kooperActionStatus->partnerActionState == PARTNER_ACTION_KOOPER_TOSS) { + if (partnerStatus->partnerActionState != PARTNER_ACTION_NONE) { + if (partnerStatus->partnerActionState == PARTNER_ACTION_KOOPER_TOSS) { N(TriggeredBattle) = TRUE; } @@ -746,8 +746,8 @@ void N(pre_battle)(Npc* kooper) { partner_clear_player_tracking(kooper); disable_npc_blur(kooper); - kooperActionStatus->actingPartner = PARTNER_NONE; - kooperActionStatus->partnerActionState = PARTNER_ACTION_NONE; + partnerStatus->actingPartner = PARTNER_NONE; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; } } diff --git a/src/world/partner/lakilester.c b/src/world/partner/lakilester.c index fbbb087b56..1cc2cfc3ba 100644 --- a/src/world/partner/lakilester.c +++ b/src/world/partner/lakilester.c @@ -5,83 +5,116 @@ #define NAMESPACE world_lakilester -BSS s32 D_802BFF00; -BSS s32 D_802BFF04; -BSS s32 D_802BFF08; -BSS s32 D_802BFF0C; -BSS s32 D_802BFF10; -BSS s32 D_802BFF14; -BSS s32 D_802BFF18; -BSS s32 D_802BFF1C; -BSS s32 D_802BFF20; -BSS s32 D_802BFF24; -BSS f32 D_802BFF28; -BSS s32 D_802BFF2C; -BSS TweesterPhysics LakilesterTweesterPhysics; +BSS s32 N(PutAwayState); +BSS b32 N(LockingPlayerInput); +BSS b32 N(PlayerCollisionDisabled); +BSS s32 N(MountState); +BSS b32 N(UpdatePushingWall); +BSS s32 N(AbilityState); +BSS s32 N(PlayerBounceOffset); +BSS s32 N(MoveSoundsTime); +BSS s32 N(MovePitchAdjustment); +BSS s32 N(MountingDeltaY); +BSS f32 N(CurrentGroundPitch); +BSS s32 N(D_802BFF2C); // unused (padding?) -void func_802BD100_320C50(void) { +enum { + RIDE_STATE_BEGIN = 40, + RIDE_STATE_DELAY = 41, + RIDE_STATE_MOUNT_1 = 100, + RIDE_STATE_MOUNT_2 = 101, + RIDE_STATE_MOUNT_3 = 102, + RIDE_STATE_MOUNT_4 = 103, + RIDE_STATE_START_RIDING = 104, // cannot dismount until this state is done + RIDE_STATE_RIDING = 1, + RIDE_STATE_DISMOUNT_1 = 3, + RIDE_STATE_DISMOUNT_2 = 4, + RIDE_STATE_DISMOUNT_3 = 5, + RIDE_STATE_FINISH_1 = 10, + RIDE_STATE_FINISH_2 = 11, +}; + +// states for putting lakilester away, paralleling ride states +enum { + PUT_AWAY_DISMOUNT_1 = 0, + PUT_AWAY_DISMOUNT_2 = 1, + PUT_AWAY_DISMOUNT_3 = 2, + PUT_AWAY_FINISH_1 = 3, + PUT_AWAY_FINISH_2 = 4, + PUT_AWAY_FINISH_3 = 5, +}; + +enum { + MOUNT_STATE_NONE = 0, + MOUNT_STATE_IN_PROGRESS = 1, + MOUNT_STATE_DONE = 2, +}; + +void N(offset_player_from_camera)(f32 arg0); + +void N(sync_player_position)(void) { PlayerStatus* playerStatus = &gPlayerStatus; Npc* lakilester = get_npc_unsafe(NPC_PARTNER); - s32 playerFlags = playerStatus->flags; - Camera* currentCamera; - f32 playerSpeedCopy; - s32 temp_v0_2; + f32 speed; - if (playerFlags & PS_FLAG_CUTSCENE_MOVEMENT) { - playerSpeedCopy = playerStatus->currentSpeed; - if (playerFlags & PS_FLAG_ENTERING_BATTLE) { - playerSpeedCopy *= 0.5f; + if (playerStatus->flags & PS_FLAG_CUTSCENE_MOVEMENT) { + speed = playerStatus->currentSpeed; + if (playerStatus->flags & PS_FLAG_ENTERING_BATTLE) { + speed *= 0.5f; } - add_vec2D_polar(&lakilester->pos.x, &lakilester->pos.z, playerSpeedCopy, playerStatus->heading); + add_vec2D_polar(&lakilester->pos.x, &lakilester->pos.z, speed, playerStatus->heading); lakilester->yaw = playerStatus->targetYaw; } - temp_v0_2 = abs(D_802BFF18); playerStatus->position.x = lakilester->pos.x; - playerStatus->position.y = lakilester->pos.y + 10.0f + (temp_v0_2 * 0.34f); + playerStatus->position.y = lakilester->pos.y + 10.0f + abs(N(PlayerBounceOffset)) * 0.34f; playerStatus->position.z = lakilester->pos.z; - currentCamera = &gCameras[gCurrentCameraID]; - add_vec2D_polar(&playerStatus->position.x, &playerStatus->position.z, 2.0f, currentCamera->currentYaw); + add_vec2D_polar(&playerStatus->position.x, &playerStatus->position.z, 2.0f, gCameras[gCurrentCameraID].currentYaw); } -void world_lakilester_init(Npc* npc) { - npc->collisionHeight = 38; - npc->collisionRadius = 36; - npc->collisionChannel = COLLISION_CHANNEL_10000; - D_802BFF18 = 0; - D_802BFF04 = 0; - D_802BFF08 = 0; - D_802BFF0C = 0; - D_802BFF10 = 1; - D_802BFF1C = 0; - D_802BFF20 = 0; - D_802BFF24 = 0; - D_802BFF28 = 0; - npc->moveToPos.x = npc->pos.x; - npc->moveToPos.y = npc->pos.y; - npc->moveToPos.z = npc->pos.z; +void N(init)(Npc* lakilester) { + lakilester->collisionHeight = 38; + lakilester->collisionRadius = 36; + lakilester->collisionChannel = COLLISION_CHANNEL_10000; + N(PlayerBounceOffset) = 0; + N(LockingPlayerInput) = FALSE; + N(PlayerCollisionDisabled) = FALSE; + N(MountState) = MOUNT_STATE_NONE; + N(UpdatePushingWall) = TRUE; + N(MoveSoundsTime) = 0; + N(MovePitchAdjustment) = 0; + N(MountingDeltaY) = 0; + N(CurrentGroundPitch) = 0; + lakilester->moveToPos.x = lakilester->pos.x; + lakilester->moveToPos.y = lakilester->pos.y; + lakilester->moveToPos.z = lakilester->pos.z; } -API_CALLABLE(func_802BD29C_320DEC) { +API_CALLABLE(N(TakeOut)) { Npc* lakilester = script->owner2.npc; if (isInitialCall) { partner_init_get_out(lakilester); } - return partner_get_out(lakilester) ? ApiStatus_DONE1 : ApiStatus_BLOCK; + if (partner_get_out(lakilester)) { + return ApiStatus_DONE1; + } else { + return ApiStatus_BLOCK; + } } EvtScript EVS_WorldLakilester_TakeOut = { - EVT_CALL(func_802BD29C_320DEC) + EVT_CALL(N(TakeOut)) EVT_RETURN EVT_END }; -TweesterPhysics* LakilesterTweesterPhysicsPtr = &LakilesterTweesterPhysics; +BSS TweesterPhysics N(TweesterPhysicsData); +TweesterPhysics* N(TweesterPhysicsPtr) = &N(TweesterPhysicsData); -API_CALLABLE(func_802BD2D4_320E24) { +API_CALLABLE(N(Update)) { PlayerData* playerData = &gPlayerData; Npc* lakilester = script->owner2.npc; f32 sinAngle, cosAngle, liftoffVelocity; @@ -89,7 +122,7 @@ API_CALLABLE(func_802BD2D4_320E24) { if (isInitialCall) { partner_flying_enable(lakilester, 1); - mem_clear(LakilesterTweesterPhysicsPtr, sizeof(TweesterPhysics)); + mem_clear(N(TweesterPhysicsPtr), sizeof(TweesterPhysics)); TweesterTouchingPartner = NULL; } @@ -103,59 +136,59 @@ API_CALLABLE(func_802BD2D4_320E24) { return ApiStatus_BLOCK; } - switch (LakilesterTweesterPhysicsPtr->state) { + switch (N(TweesterPhysicsPtr)->state) { case TWEESTER_PARTNER_INIT: - LakilesterTweesterPhysicsPtr->state++; - LakilesterTweesterPhysicsPtr->prevFlags = lakilester->flags; - LakilesterTweesterPhysicsPtr->radius = fabsf(dist2D(lakilester->pos.x, lakilester->pos.z, entity->position.x, entity->position.z)); - LakilesterTweesterPhysicsPtr->angle = atan2(entity->position.x, entity->position.z, lakilester->pos.x, lakilester->pos.z); - LakilesterTweesterPhysicsPtr->angularVelocity = 6.0f; - LakilesterTweesterPhysicsPtr->liftoffVelocityPhase = 50.0f; - LakilesterTweesterPhysicsPtr->countdown = 120; + N(TweesterPhysicsPtr)->state++; + N(TweesterPhysicsPtr)->prevFlags = lakilester->flags; + N(TweesterPhysicsPtr)->radius = fabsf(dist2D(lakilester->pos.x, lakilester->pos.z, entity->position.x, entity->position.z)); + N(TweesterPhysicsPtr)->angle = atan2(entity->position.x, entity->position.z, lakilester->pos.x, lakilester->pos.z); + N(TweesterPhysicsPtr)->angularVelocity = 6.0f; + N(TweesterPhysicsPtr)->liftoffVelocityPhase = 50.0f; + N(TweesterPhysicsPtr)->countdown = 120; lakilester->flags |= NPC_FLAG_IGNORE_CAMERA_FOR_YAW | NPC_FLAG_IGNORE_PLAYER_COLLISION | NPC_FLAG_IGNORE_WORLD_COLLISION | NPC_FLAG_8; lakilester->flags &= ~NPC_FLAG_GRAVITY; case TWEESTER_PARTNER_ATTRACT: - sin_cos_rad(DEG_TO_RAD(LakilesterTweesterPhysicsPtr->angle), &sinAngle, &cosAngle); - lakilester->pos.x = entity->position.x + (sinAngle * LakilesterTweesterPhysicsPtr->radius); - lakilester->pos.z = entity->position.z - (cosAngle * LakilesterTweesterPhysicsPtr->radius); - LakilesterTweesterPhysicsPtr->angle = clamp_angle(LakilesterTweesterPhysicsPtr->angle - LakilesterTweesterPhysicsPtr->angularVelocity); + sin_cos_rad(DEG_TO_RAD(N(TweesterPhysicsPtr)->angle), &sinAngle, &cosAngle); + lakilester->pos.x = entity->position.x + (sinAngle * N(TweesterPhysicsPtr)->radius); + lakilester->pos.z = entity->position.z - (cosAngle * N(TweesterPhysicsPtr)->radius); + N(TweesterPhysicsPtr)->angle = clamp_angle(N(TweesterPhysicsPtr)->angle - N(TweesterPhysicsPtr)->angularVelocity); - if (LakilesterTweesterPhysicsPtr->radius > 20.0f) { - LakilesterTweesterPhysicsPtr->radius--; - } else if (LakilesterTweesterPhysicsPtr->radius < 19.0f) { - LakilesterTweesterPhysicsPtr->radius++; + if (N(TweesterPhysicsPtr)->radius > 20.0f) { + N(TweesterPhysicsPtr)->radius--; + } else if (N(TweesterPhysicsPtr)->radius < 19.0f) { + N(TweesterPhysicsPtr)->radius++; } - liftoffVelocity = sin_rad(DEG_TO_RAD(LakilesterTweesterPhysicsPtr->liftoffVelocityPhase)) * 3.0f; - LakilesterTweesterPhysicsPtr->liftoffVelocityPhase += 3.0f; + liftoffVelocity = sin_rad(DEG_TO_RAD(N(TweesterPhysicsPtr)->liftoffVelocityPhase)) * 3.0f; + N(TweesterPhysicsPtr)->liftoffVelocityPhase += 3.0f; - if (LakilesterTweesterPhysicsPtr->liftoffVelocityPhase > 150.0f) { - LakilesterTweesterPhysicsPtr->liftoffVelocityPhase = 150.0f; + if (N(TweesterPhysicsPtr)->liftoffVelocityPhase > 150.0f) { + N(TweesterPhysicsPtr)->liftoffVelocityPhase = 150.0f; } lakilester->pos.y += liftoffVelocity; - lakilester->renderYaw = clamp_angle(360.0f - LakilesterTweesterPhysicsPtr->angle); - LakilesterTweesterPhysicsPtr->angularVelocity += 0.8; + lakilester->renderYaw = clamp_angle(360.0f - N(TweesterPhysicsPtr)->angle); + N(TweesterPhysicsPtr)->angularVelocity += 0.8; - if (LakilesterTweesterPhysicsPtr->angularVelocity > 40.0f) { - LakilesterTweesterPhysicsPtr->angularVelocity = 40.0f; + if (N(TweesterPhysicsPtr)->angularVelocity > 40.0f) { + N(TweesterPhysicsPtr)->angularVelocity = 40.0f; } - if (--LakilesterTweesterPhysicsPtr->countdown == 0) { - LakilesterTweesterPhysicsPtr->state++; + if (--N(TweesterPhysicsPtr)->countdown == 0) { + N(TweesterPhysicsPtr)->state++; } break; case TWEESTER_PARTNER_HOLD: - lakilester->flags = LakilesterTweesterPhysicsPtr->prevFlags; - LakilesterTweesterPhysicsPtr->countdown = 30; - LakilesterTweesterPhysicsPtr->state++; + lakilester->flags = N(TweesterPhysicsPtr)->prevFlags; + N(TweesterPhysicsPtr)->countdown = 30; + N(TweesterPhysicsPtr)->state++; break; case TWEESTER_PARTNER_RELEASE: partner_flying_update_player_tracking(lakilester); partner_flying_update_motion(lakilester); - if (--LakilesterTweesterPhysicsPtr->countdown == 0) { - LakilesterTweesterPhysicsPtr->state = TWEESTER_PARTNER_INIT; + if (--N(TweesterPhysicsPtr)->countdown == 0) { + N(TweesterPhysicsPtr)->state = TWEESTER_PARTNER_INIT; TweesterTouchingPartner = NULL; } break; @@ -164,103 +197,105 @@ API_CALLABLE(func_802BD2D4_320E24) { } EvtScript EVS_WorldLakilester_Update = { - EVT_CALL(func_802BD2D4_320E24) + EVT_CALL(N(Update)) EVT_RETURN EVT_END }; -void lakilester_try_cancel_tweester(Npc* npc) { +void N(try_cancel_tweester)(Npc* lakilester) { if (TweesterTouchingPartner != NULL) { TweesterTouchingPartner = NULL; - npc->flags = LakilesterTweesterPhysicsPtr->prevFlags; - LakilesterTweesterPhysicsPtr->state = TWEESTER_PARTNER_INIT; - partner_clear_player_tracking(npc); + lakilester->flags = N(TweesterPhysicsPtr)->prevFlags; + N(TweesterPhysicsPtr)->state = TWEESTER_PARTNER_INIT; + partner_clear_player_tracking(lakilester); } } -void func_802BD6BC_32120C(f32* outAngle, f32* outMagnitude) { - PartnerActionStatus* lakilesterActionStatus = &gPartnerActionStatus; - f32 stickX = lakilesterActionStatus->stickX; - f32 stickY = lakilesterActionStatus->stickY; - f32 angle = clamp_angle(atan2(0.0f, 0.0f, stickX, -stickY) + gCameras[CAM_DEFAULT].currentYaw); - f32 magnitude = 0.0f; +void N(get_movement_from_input)(f32* outAngle, f32* outSpeed) { + PartnerStatus* partnerStatus = &gPartnerStatus; + f32 stickX = partnerStatus->stickX; + f32 stickY = partnerStatus->stickY; + f32 moveAngle = clamp_angle(atan2(0.0f, 0.0f, stickX, -stickY) + gCameras[CAM_DEFAULT].currentYaw); + f32 moveSpeed = 0.0f; if (dist2D(0.0f, 0.0f, stickX, -stickY) >= 1.0) { - magnitude = 3.0f; - if (SQ(stickX) + SQ(stickY) > 3025.0f) { - magnitude = 6.0f; + moveSpeed = 3.0f; + if (SQ(stickX) + SQ(stickY) > SQ(55)) { + moveSpeed = 6.0f; } } - *outAngle = angle; - *outMagnitude = magnitude; + *outAngle = moveAngle; + *outSpeed = moveSpeed; } -// Returns whether or not it is safe to dismount Lakilester -s32 lakilester_raycast_below(void) { +s32 N(can_dismount)(void) { PlayerStatus* playerStatus = &gPlayerStatus; Camera* currentCamera; f32 hitDirX, hitDirZ; f32 hitRx, hitRz; f32 outX, outY, outZ, outLength; - Npc* npc = get_npc_unsafe(NPC_PARTNER); - s32 colliderTypeID; - s32 raycastResult; - s32 ret; + Npc* lakilester = get_npc_unsafe(NPC_PARTNER); + s32 temp; + s32 hitResult; + s32 canDismount; + s32 entityType; if (playerStatus->animFlags & PA_FLAG_DISMOUNTING_ALLOWED) { playerStatus->animFlags &= ~PA_FLAG_DISMOUNTING_ALLOWED; return TRUE; } - ret = FALSE; + canDismount = FALSE; outLength = 16.0f; - outY = npc->moveToPos.y + 7.0f; + outY = lakilester->moveToPos.y + 7.0f; outX = playerStatus->position.x; outZ = playerStatus->position.z; currentCamera = &gCameras[gCurrentCameraID]; add_vec2D_polar(&outX, &outZ, 2.0f, currentCamera->currentYaw); - raycastResult = player_raycast_below_cam_relative(playerStatus, &outX, &outY, &outZ, &outLength, &hitRx, &hitRz, + hitResult = player_raycast_below_cam_relative(playerStatus, &outX, &outY, &outZ, &outLength, &hitRx, &hitRz, &hitDirX, &hitDirZ); - colliderTypeID = raycastResult; + temp = hitResult; //TODO find better match - if (outLength <= 16.0f && colliderTypeID >= 0) { - if (!(colliderTypeID & COLLISION_WITH_ENTITY_BIT) || !(get_entity_type(colliderTypeID) - 0x2E < 2)){ - colliderTypeID = get_collider_flags(colliderTypeID) & 0xFF; //TODO surface type - if (!(colliderTypeID == SURFACE_TYPE_WATER || colliderTypeID == SURFACE_TYPE_SPIKES || colliderTypeID == SURFACE_TYPE_LAVA)) { // - ret = FALSE; - if (colliderTypeID != SURFACE_TYPE_SLIDE) { - npc->moveToPos.x = outX; - npc->moveToPos.y = outY; - npc->moveToPos.z = outZ; - ret = TRUE; + if (outLength <= 16.0f && temp >= 0) { + if (!(temp & COLLISION_WITH_ENTITY_BIT) || + (entityType = get_entity_type(temp), + !(entityType == ENTITY_TYPE_SIMPLE_SPRING || entityType == ENTITY_TYPE_SCRIPT_SPRING)) + ) { + temp = get_collider_flags(temp) & COLLIDER_FLAGS_SURFACE_TYPE_MASK; //TODO 'temp' is now 'surfaceType' + if (!(temp == SURFACE_TYPE_WATER || temp == SURFACE_TYPE_SPIKES || temp == SURFACE_TYPE_LAVA)) { + if (temp != SURFACE_TYPE_SLIDE) { + lakilester->moveToPos.x = outX; + lakilester->moveToPos.y = outY; + lakilester->moveToPos.z = outZ; + canDismount = TRUE; } } } } - - return ret; + return canDismount; } -s32 func_802BD99C_3214EC(Npc* partner, f32 yOffset, f32 zOffset) { - f32 outX = gPlayerStatus.position.x; - f32 outY = gPlayerStatus.position.y + yOffset; - f32 outZ = gPlayerStatus.position.z; - f32 outLength = zOffset; +s32 N(test_mounting_height_adjustment)(Npc* lakilester, f32 height, f32 dist) { + f32 x = gPlayerStatus.position.x; + f32 y = gPlayerStatus.position.y + height; + f32 z = gPlayerStatus.position.z; + f32 depth = dist; f32 hitRx, hitRz; f32 hitDirX, hitDirZ; f32 deltaY; - D_802BFF24 = 0; + N(MountingDeltaY) = 0; - if (player_raycast_below_cam_relative(&gPlayerStatus, &outX, &outY, &outZ, &outLength, &hitRx, &hitRz, - &hitDirX, &hitDirZ) >= 0) { - deltaY = outY - partner->moveToPos.y; + if (player_raycast_below_cam_relative(&gPlayerStatus, &x, &y, &z, &depth, + &hitRx, &hitRz, &hitDirX, &hitDirZ) > NO_COLLIDER) + { + deltaY = y - lakilester->moveToPos.y; if (deltaY != 0.0f) { if (fabs(deltaY) < 10.0) { - D_802BFF24 = deltaY; - partner->moveToPos.y = outY; + N(MountingDeltaY) = deltaY; + lakilester->moveToPos.y = y; return TRUE; } else { return FALSE; @@ -271,7 +306,7 @@ s32 func_802BD99C_3214EC(Npc* partner, f32 yOffset, f32 zOffset) { return FALSE; } -void func_802BDA90_3215E0(Npc* lakilester) { +void N(apply_riding_static_collisions)(Npc* lakilester) { f32 radius = lakilester->collisionRadius * 0.8f; f32 x, y, z, yaw; @@ -327,13 +362,12 @@ void func_802BDA90_3215E0(Npc* lakilester) { } } -void func_802BDDD8_321928(Npc* npc) { +void N(update_riding_physics)(Npc* lakilester) { PlayerStatus* playerStatus = &gPlayerStatus; CollisionStatus* collisionStatus = &gCollisionStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; - f32 hitDepth, sp40, sp44, sp48, sp4C, sp50, sp54; - f32 yaw = 0.0f; - f32 moveSpeed = 0.0f; + PartnerStatus* partnerStatus = &gPartnerStatus; + f32 hitDepth, sp40, sp44, sp48, sp4C, sinAngle, cosAngle; + f32 moveAngle, moveSpeed; f32 x, y, z; f32 temp_f0_3; s32 raycastBelowResult; @@ -342,207 +376,204 @@ void func_802BDDD8_321928(Npc* npc) { s32 pitchShift; f32 height; - func_802BD6BC_32120C(&yaw, &moveSpeed); + moveAngle = 0.0f; + moveSpeed = 0.0f; + N(get_movement_from_input)(&moveAngle, &moveSpeed); - currentSurfaceType = get_collider_flags(npc->currentFloor) & 0xFF; + currentSurfaceType = get_collider_flags(lakilester->currentFloor) & COLLIDER_FLAGS_SURFACE_TYPE_MASK; if (currentSurfaceType == SURFACE_TYPE_LAVA) { moveSpeed *= 0.5f; } - if (D_802BFF28 >= 20.0f) { + if (N(CurrentGroundPitch) >= 20.0f) { moveSpeed *= 0.8f; } - npc->moveSpeed = moveSpeed; + lakilester->moveSpeed = moveSpeed; if (moveSpeed != 0.0f) { - D_802BFF1C += 1; - D_802BFF20 += 1; - if (!(D_802BFF1C & 7)) { - if (D_802BFF20 >= 120) { - D_802BFF20 = 0; + N(MoveSoundsTime)++; + N(MovePitchAdjustment)++; + if (N(MoveSoundsTime) % 8 == 0) { + if (N(MovePitchAdjustment) >= 120) { + N(MovePitchAdjustment) = 0; } - if (D_802BFF20 < 0x3C) { - pitchShift = update_lerp(0, 0.0f, 100.0f, D_802BFF20, 60); - sfx_play_sound_with_params(SOUND_295, 0, 0x40, pitchShift); + if (N(MovePitchAdjustment) < 60) { + pitchShift = update_lerp(EASING_LINEAR, 0.0f, 100.0f, N(MovePitchAdjustment), 60); + sfx_play_sound_with_params(SOUND_295, 0, 64, pitchShift); } else { - pitchShift = update_lerp(0, 100.0f, 0.0f, D_802BFF20 - 60, 60); - sfx_play_sound_with_params(SOUND_295, 0, 0x40, pitchShift); + pitchShift = update_lerp(EASING_LINEAR, 100.0f, 0.0f, N(MovePitchAdjustment) - 60, 60); + sfx_play_sound_with_params(SOUND_295, 0, 64, pitchShift); } } } - x = npc->pos.x; - y = npc->moveToPos.y; - z = npc->pos.z; + x = lakilester->pos.x; + y = lakilester->moveToPos.y; + z = lakilester->pos.z; - if (npc_test_move_taller_with_slipping(npc->collisionChannel, &x, &y, &z, npc->collisionRadius, npc->yaw, - npc->collisionHeight, npc->collisionRadius) != 0) { - - collisionStatus->currentInspect = (partnerActionStatus->pressedButtons & BUTTON_A) ? NpcHitQueryColliderID : NO_COLLIDER; + if (npc_test_move_taller_with_slipping(lakilester->collisionChannel, &x, &y, &z, + lakilester->collisionRadius, lakilester->yaw, lakilester->collisionHeight, lakilester->collisionRadius)) + { + collisionStatus->currentInspect = (partnerStatus->pressedButtons & BUTTON_A) ? NpcHitQueryColliderID : NO_COLLIDER; } if (moveSpeed != 0.0f) { - npc->yaw = yaw; - x = npc->pos.x; - y = npc->moveToPos.y; - z = npc->pos.z; - - if (npc_test_move_complex_with_slipping(npc->collisionChannel, &x, &y, &z, npc->moveSpeed, npc->yaw, - npc->collisionHeight, npc->collisionRadius) != 0) { - - if (D_802BFF10) { + lakilester->yaw = moveAngle; + x = lakilester->pos.x; + y = lakilester->moveToPos.y; + z = lakilester->pos.z; + if (npc_test_move_complex_with_slipping(lakilester->collisionChannel, &x, &y, &z, + lakilester->moveSpeed, lakilester->yaw, lakilester->collisionHeight, lakilester->collisionRadius)) + { + if (N(UpdatePushingWall)) { collisionStatus->pushingAgainstWall = NpcHitQueryColliderID; } - npc->pos.x += (x - npc->pos.x) / 5.0f; - npc->pos.z += (z - npc->pos.z) / 5.0f; + lakilester->pos.x += (x - lakilester->pos.x) / 5.0f; + lakilester->pos.z += (z - lakilester->pos.z) / 5.0f; } else { - npc_move_heading(npc, npc->moveSpeed, yaw); - if (D_802BFF10) { + npc_move_heading(lakilester, lakilester->moveSpeed, moveAngle); + if (N(UpdatePushingWall)) { collisionStatus->pushingAgainstWall = NO_COLLIDER; } } - yaw = clamp_angle(npc->yaw - 30.0f); - x = npc->pos.x; - y = npc->moveToPos.y; - z = npc->pos.z; - - if (npc_test_move_taller_with_slipping(npc->collisionChannel, &x, &y, &z, npc->moveSpeed, yaw, - npc->collisionHeight, npc->collisionRadius) != 0) { - - npc->pos.x += (x - npc->pos.x) / 5.0f; - npc->pos.z += (z - npc->pos.z) / 5.0f; + moveAngle = clamp_angle(lakilester->yaw - 30.0f); + x = lakilester->pos.x; + y = lakilester->moveToPos.y; + z = lakilester->pos.z; + if (npc_test_move_taller_with_slipping(lakilester->collisionChannel, &x, &y, &z, + lakilester->moveSpeed, moveAngle, lakilester->collisionHeight, lakilester->collisionRadius)) + { + lakilester->pos.x += (x - lakilester->pos.x) / 5.0f; + lakilester->pos.z += (z - lakilester->pos.z) / 5.0f; } - yaw = clamp_angle(npc->yaw + 30.0f); - x = npc->pos.x; - y = npc->moveToPos.y; - z = npc->pos.z; - if (npc_test_move_taller_with_slipping(npc->collisionChannel, &x, &y, &z, npc->moveSpeed, yaw, - npc->collisionHeight, npc->collisionRadius) != 0) { - - npc->pos.x += (x - npc->pos.x) / 5.0f; - npc->pos.z += (z - npc->pos.z) / 5.0f; + moveAngle = clamp_angle(lakilester->yaw + 30.0f); + x = lakilester->pos.x; + y = lakilester->moveToPos.y; + z = lakilester->pos.z; + if (npc_test_move_taller_with_slipping(lakilester->collisionChannel, &x, &y, &z, + lakilester->moveSpeed, moveAngle, lakilester->collisionHeight, lakilester->collisionRadius)) + { + lakilester->pos.x += (x - lakilester->pos.x) / 5.0f; + lakilester->pos.z += (z - lakilester->pos.z) / 5.0f; } - spawn_surface_effects(npc, SURFACE_INTERACT_RUN); + spawn_surface_effects(lakilester, SURFACE_INTERACT_RUN); } else { - yaw = 90.0f; - x = npc->pos.x; - y = npc->moveToPos.y; - z = npc->pos.z; - - if (npc_test_move_taller_with_slipping(npc->collisionChannel, &x, &y, &z, 4.0f, yaw, npc->collisionHeight, - npc->collisionRadius) != 0) { - - npc->pos.x += (x - npc->pos.x) / 5.0f; - npc->pos.z += (z - npc->pos.z) / 5.0f; + moveAngle = 90.0f; + x = lakilester->pos.x; + y = lakilester->moveToPos.y; + z = lakilester->pos.z; + if (npc_test_move_taller_with_slipping(lakilester->collisionChannel, &x, &y, &z, + 4.0f, moveAngle, lakilester->collisionHeight, lakilester->collisionRadius)) + { + lakilester->pos.x += (x - lakilester->pos.x) / 5.0f; + lakilester->pos.z += (z - lakilester->pos.z) / 5.0f; } - yaw = 270.0f; - x = npc->pos.x; - y = npc->moveToPos.y; - z = npc->pos.z; - - if (npc_test_move_taller_with_slipping(npc->collisionChannel, &x, &y, &z, 4.0f, yaw, npc->collisionHeight, - npc->collisionRadius) != 0) { - - npc->pos.x += (x - npc->pos.x) / 5.0f; - npc->pos.z += (z - npc->pos.z) / 5.0f; + moveAngle = 270.0f; + x = lakilester->pos.x; + y = lakilester->moveToPos.y; + z = lakilester->pos.z; + if (npc_test_move_taller_with_slipping(lakilester->collisionChannel, &x, &y, &z, + 4.0f, moveAngle, lakilester->collisionHeight, lakilester->collisionRadius)) + { + lakilester->pos.x += (x - lakilester->pos.x) / 5.0f; + lakilester->pos.z += (z - lakilester->pos.z) / 5.0f; } } - func_802BDA90_3215E0(npc); - npc->moveToPos.y -= npc->jumpScale; - hitDepth = npc->collisionHeight + 2; - y = npc->moveToPos.y + 12.0f; + N(apply_riding_static_collisions)(lakilester); + lakilester->moveToPos.y -= lakilester->jumpScale; + hitDepth = lakilester->collisionHeight + 2; + y = lakilester->moveToPos.y + 12.0f; x = playerStatus->position.x; z = playerStatus->position.z; add_vec2D_polar(&x, &z, 2.0f, gCameras[gCurrentCameraID].currentYaw); raycastBelowResult = player_raycast_below_cam_relative(playerStatus, &x, &y, &z, &hitDepth, &sp40, &sp44, &sp48, &sp4C); - D_802BFF28 = get_player_normal_pitch(); + N(CurrentGroundPitch) = get_player_normal_pitch(); height = 12.0f; - if (D_802BFF28 != 0.0f) { + if (N(CurrentGroundPitch) != 0.0f) { height = 32.0f; } - if (D_802BFF28 > 0.0f && raycastBelowResult >= 0) { - sin_cos_rad(DEG_TO_RAD(D_802BFF28), &sp50, &sp54); - npc->pos.y = (npc->pos.y + fabs((sp50 / sp54) * playerStatus->runSpeed)); + if (N(CurrentGroundPitch) > 0.0f && raycastBelowResult >= 0) { + sin_cos_rad(DEG_TO_RAD(N(CurrentGroundPitch)), &sinAngle, &cosAngle); + lakilester->pos.y = (lakilester->pos.y + fabs((sinAngle / cosAngle) * playerStatus->runSpeed)); } - if (hitDepth <= height && raycastBelowResult >= 0) { - playerStatus->lastGoodPosition.x = npc->pos.x; - playerStatus->lastGoodPosition.y = npc->pos.y; - playerStatus->lastGoodPosition.z = npc->pos.z; + if (hitDepth <= height && raycastBelowResult > NO_COLLIDER) { + playerStatus->lastGoodPosition.x = lakilester->pos.x; + playerStatus->lastGoodPosition.y = lakilester->pos.y; + playerStatus->lastGoodPosition.z = lakilester->pos.z; collisionStatus->currentFloor = raycastBelowResult; - npc->currentFloor = raycastBelowResult; - npc->moveToPos.y = y; - npc->moveToPos.x = x; - npc->moveToPos.z = z; - npc->jumpScale = 0.0f; + lakilester->currentFloor = raycastBelowResult; + lakilester->moveToPos.y = y; + lakilester->moveToPos.x = x; + lakilester->moveToPos.z = z; + lakilester->jumpScale = 0.0f; playerStatus->timeInAir = 0; - belowSurfaceType = get_collider_flags(raycastBelowResult) & 0xFF; + belowSurfaceType = get_collider_flags(raycastBelowResult) & COLLIDER_FLAGS_SURFACE_TYPE_MASK; if (belowSurfaceType == SURFACE_TYPE_LAVA) { - npc->currentAnim = ANIM_WorldLakilester_StrainWalk; - npc->moveSpeed = moveSpeed * 0.5f; + lakilester->currentAnim = ANIM_WorldLakilester_StrainWalk; + lakilester->moveSpeed = moveSpeed * 0.5f; } else { - npc->currentAnim = ANIM_WorldLakilester_Walk; - npc->moveSpeed = moveSpeed; + lakilester->currentAnim = ANIM_WorldLakilester_Walk; + lakilester->moveSpeed = moveSpeed; } return; } collisionStatus->currentFloor = NO_COLLIDER; playerStatus->timeInAir++; - npc->currentFloor = NO_COLLIDER; - npc->jumpScale += 1.8; + lakilester->currentFloor = NO_COLLIDER; + lakilester->jumpScale += 1.8; - if (npc->jumpScale > 12.0f) { - npc->jumpScale = 12.0f; + if (lakilester->jumpScale > 12.0f) { + lakilester->jumpScale = 12.0f; } } -s32 func_802BE6A0_3221F0(f32* arg0) { +s32 N(test_dismount_height)(f32* posY) { f32 colliderHeight = gPlayerStatus.colliderHeight; f32 hitDirX, hitDirZ; f32 hitRx, hitRz; - f32 x, z; + f32 posX, posZ; - *arg0 = gPlayerStatus.position.y + colliderHeight; - x = gPlayerStatus.position.x; - z = gPlayerStatus.position.z; + *posY = gPlayerStatus.position.y + colliderHeight; + posX = gPlayerStatus.position.x; + posZ = gPlayerStatus.position.z; - player_raycast_below_cam_relative(&gPlayerStatus, &x, arg0, &z, &colliderHeight, &hitRx, &hitRz, - &hitDirX, &hitDirZ); + return player_raycast_below_cam_relative(&gPlayerStatus, &posX, posY, &posZ, + &colliderHeight, &hitRx, &hitRz, &hitDirX, &hitDirZ); } -API_CALLABLE(LakilesterUseAbility) { +API_CALLABLE(N(UseAbility)) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; Camera* camera = &gCameras[CAM_DEFAULT]; - Npc* npc = script->owner2.npc; - s32 colliderHeightTemp; - f32 x, y, z, sp2C; + Npc* lakilester = script->owner2.npc; + f32 x, y, z, dist; f32 yaw, camYaw; s32 i; playerStatus->animFlags &= ~PA_FLAG_RIDING_PARTNER; if (isInitialCall) { - lakilester_try_cancel_tweester(npc); + N(try_cancel_tweester)(lakilester); if (!(playerStatus->animFlags & PA_FLAG_CHANGING_MAP)) { - npc->flags = npc->flags & ~PA_FLAG_PULSE_STONE_VISIBLE; - npc->moveToPos.x = npc->pos.x; - npc->moveToPos.y = npc->pos.y; - npc->moveToPos.z = npc->pos.z; + lakilester->flags = lakilester->flags & ~PA_FLAG_PULSE_STONE_VISIBLE; + lakilester->moveToPos.x = lakilester->pos.x; + lakilester->moveToPos.y = lakilester->pos.y; + lakilester->moveToPos.z = lakilester->pos.z; if (gGameStatusPtr->keepUsingPartnerOnMapChange || (playerStatus->animFlags & PA_FLAG_PARTNER_USAGE_FORCED) @@ -550,13 +581,13 @@ API_CALLABLE(LakilesterUseAbility) { if (playerStatus->animFlags & PA_FLAG_PARTNER_USAGE_FORCED) { playerStatus->animFlags &= ~PA_FLAG_PARTNER_USAGE_FORCED; } - D_802BFF14 = 100; + N(AbilityState) = RIDE_STATE_MOUNT_1; } else { - D_802BFF14 = 40; + N(AbilityState) = RIDE_STATE_BEGIN; } - if (!partnerActionStatus->partnerAction_unk_1) { - if (gGameStatusPtr->keepUsingPartnerOnMapChange == FALSE) { + if (!partnerStatus->shouldResumeAbility) { + if (!gGameStatusPtr->keepUsingPartnerOnMapChange) { if (playerStatus->actionState == ACTION_STATE_RIDE || playerStatus->actionState == ACTION_STATE_IDLE || playerStatus->actionState == ACTION_STATE_WALK @@ -569,65 +600,63 @@ API_CALLABLE(LakilesterUseAbility) { } } } else { - partnerActionStatus->partnerAction_unk_1 = FALSE; + partnerStatus->shouldResumeAbility = FALSE; playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED; - npc->flags &= ~(NPC_FLAG_IGNORE_WORLD_COLLISION | NPC_FLAG_8); - npc->flags |= NPC_FLAG_IGNORE_PLAYER_COLLISION; + lakilester->flags &= ~(NPC_FLAG_IGNORE_WORLD_COLLISION | NPC_FLAG_8); + lakilester->flags |= NPC_FLAG_IGNORE_PLAYER_COLLISION; set_action_state(ACTION_STATE_RIDE); suggest_player_anim_always_forward(ANIM_MarioW2_RideLaki); - npc->currentAnim = ANIM_WorldLakilester_Walk; - D_802BFF0C = 1; - npc->flags &= ~(NPC_FLAG_IGNORE_WORLD_COLLISION | NPC_FLAG_8); - npc->flags |= (NPC_FLAG_IGNORE_PLAYER_COLLISION | NPC_FLAG_TOUCHES_GROUND); - partnerActionStatus->actingPartner = PARTNER_LAKILESTER; - partnerActionStatus->partnerActionState = PARTNER_ACTION_LAKILESTER_1; - gGameStatusPtr->keepUsingPartnerOnMapChange = 0; - npc->pos.x = playerStatus->position.x; - npc->pos.y = npc->moveToPos.y; - npc->pos.z = playerStatus->position.z; - npc->currentAnim = ANIM_WorldLakilester_Walk; - playerStatus->position.y = npc->pos.y + 10.0f; - npc->moveSpeed = 3.0f; - npc->jumpScale = 0.0f; - npc->yaw = playerStatus->targetYaw; + lakilester->currentAnim = ANIM_WorldLakilester_Walk; + N(MountState) = MOUNT_STATE_IN_PROGRESS; // unexpected + lakilester->flags &= ~(NPC_FLAG_IGNORE_WORLD_COLLISION | NPC_FLAG_8); + lakilester->flags |= (NPC_FLAG_IGNORE_PLAYER_COLLISION | NPC_FLAG_TOUCHES_GROUND); + partnerStatus->actingPartner = PARTNER_LAKILESTER; + partnerStatus->partnerActionState = PARTNER_ACTION_LAKILESTER_1; + gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; + lakilester->pos.x = playerStatus->position.x; + lakilester->pos.y = lakilester->moveToPos.y; + lakilester->pos.z = playerStatus->position.z; + lakilester->currentAnim = ANIM_WorldLakilester_Walk; + playerStatus->position.y = lakilester->pos.y + 10.0f; + lakilester->moveSpeed = 3.0f; + lakilester->jumpScale = 0.0f; + lakilester->yaw = playerStatus->targetYaw; suggest_player_anim_always_forward(ANIM_MarioW2_RideLaki); set_action_state(ACTION_STATE_RIDE); disable_player_static_collisions(); - D_802BFF08 = 1; + N(PlayerCollisionDisabled) = TRUE; - if (D_802BFF04 == 0) { + if (!N(LockingPlayerInput)) { disable_player_input(); - D_802BFF04 = 1; + N(LockingPlayerInput) = TRUE; } - D_802BFF18 = 0; - D_802BFF14 = 1; - npc->flags |= NPC_FLAG_IGNORE_WORLD_COLLISION; + N(PlayerBounceOffset) = 0; + N(AbilityState) = RIDE_STATE_RIDING; + lakilester->flags |= NPC_FLAG_IGNORE_WORLD_COLLISION; } } else { return ApiStatus_DONE2; } } - switch (D_802BFF14) { - case 40: - if (playerStatus->flags & PS_FLAG_HIT_FIRE || - playerStatus->inputDisabledCount) { - + switch (N(AbilityState)) { + case RIDE_STATE_BEGIN: + if (playerStatus->flags & PS_FLAG_HIT_FIRE || playerStatus->inputDisabledCount != 0) { playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED; return ApiStatus_DONE2; } script->functionTemp[1] = 3; script->functionTemp[2] = disable_player_input(); - D_802BFF04 = 1; - D_802BFF14 += 1; + N(LockingPlayerInput) = TRUE; + N(AbilityState)++; // RIDE_STATE_DELAY break; - case 41: + case RIDE_STATE_DELAY: if (playerStatus->flags & PS_FLAG_HIT_FIRE) { playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED; - if (D_802BFF04 != 0) { + if (N(LockingPlayerInput)) { enable_player_input(); - D_802BFF04 = 0; + N(LockingPlayerInput) = FALSE; } return ApiStatus_DONE2; } @@ -635,7 +664,7 @@ API_CALLABLE(LakilesterUseAbility) { if (playerStatus->animFlags & PA_FLAG_CHANGING_MAP) { if (script->functionTemp[2] < playerStatus->inputDisabledCount) { enable_player_input(); - D_802BFF04 = 0; + N(LockingPlayerInput) = FALSE; } playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED; return ApiStatus_DONE2; @@ -644,192 +673,191 @@ API_CALLABLE(LakilesterUseAbility) { if (script->functionTemp[1] == 0) { if (script->functionTemp[2] < playerStatus->inputDisabledCount) { enable_player_input(); - D_802BFF04 = 0; + N(LockingPlayerInput) = FALSE; playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED; return ApiStatus_DONE2; } - D_802BFF14 = 100; + N(AbilityState) = RIDE_STATE_MOUNT_1; break; } script->functionTemp[1]--; break; } - switch (D_802BFF14) { - case 100: + switch (N(AbilityState)) { + case RIDE_STATE_MOUNT_1: disable_player_static_collisions(); - D_802BFF08 = 1; + N(PlayerCollisionDisabled) = TRUE; - if (D_802BFF04 == 0) { + if (!N(LockingPlayerInput)) { disable_player_input(); - D_802BFF04 = 1; + N(LockingPlayerInput) = TRUE; } - npc->flags &= ~NPC_FLAG_8; - npc->flags |= (NPC_FLAG_TOUCHES_GROUND | NPC_FLAG_IGNORE_PLAYER_COLLISION); + lakilester->flags &= ~NPC_FLAG_8; + lakilester->flags |= (NPC_FLAG_TOUCHES_GROUND | NPC_FLAG_IGNORE_PLAYER_COLLISION); set_action_state(ACTION_STATE_RIDE); - D_802BFF0C = 1; + N(MountState) = MOUNT_STATE_IN_PROGRESS; partner_force_player_flip_done(); - npc->moveToPos.x = playerStatus->position.x; - npc->moveToPos.y = playerStatus->position.y; - npc->moveToPos.z = playerStatus->position.z; + lakilester->moveToPos.x = playerStatus->position.x; + lakilester->moveToPos.y = playerStatus->position.y; + lakilester->moveToPos.z = playerStatus->position.z; yaw = 0.0f; for (i = 0; i < 4; i++) { - x = npc->moveToPos.x; - y = npc->moveToPos.y; - z = npc->moveToPos.z; - npc_test_move_simple_with_slipping(0x10000, &x, &y, &z, npc->moveSpeed, - yaw, npc->collisionHeight, npc->collisionRadius); - npc->moveToPos.x = x; - npc->moveToPos.y = y; - npc->moveToPos.z = z; + x = lakilester->moveToPos.x; + y = lakilester->moveToPos.y; + z = lakilester->moveToPos.z; + npc_test_move_simple_with_slipping(COLLISION_CHANNEL_10000, &x, &y, &z, lakilester->moveSpeed, + yaw, lakilester->collisionHeight, lakilester->collisionRadius); + lakilester->moveToPos.x = x; + lakilester->moveToPos.y = y; + lakilester->moveToPos.z = z; yaw += 90.0f; } - npc->yaw = atan2(npc->pos.x, npc->pos.z, npc->moveToPos.x, npc->moveToPos.z); - npc->duration = 12; - npc->currentAnim = ANIM_WorldLakilester_Walk; - npc->jumpVelocity = 8.0f; - npc->jumpScale = 1.4f; + lakilester->yaw = atan2(lakilester->pos.x, lakilester->pos.z, lakilester->moveToPos.x, lakilester->moveToPos.z); + lakilester->duration = 12; + lakilester->currentAnim = ANIM_WorldLakilester_Walk; + lakilester->jumpVelocity = 8.0f; + lakilester->jumpScale = 1.4f; suggest_player_anim_allow_backward(ANIM_Mario1_BeforeJump); - D_802BFF14 = 101; + N(AbilityState) = RIDE_STATE_MOUNT_2; break; - case 101: + case RIDE_STATE_MOUNT_2: sfx_play_sound_at_npc(SOUND_JUMP_2081, SOUND_SPACE_MODE_0, NPC_PARTNER); suggest_player_anim_allow_backward(ANIM_Mario1_Jump); - /* fallthrough */ - case 102: - D_802BFF14++; - /* fallthrough */ - case 103: + // fallthrough + case RIDE_STATE_MOUNT_3: + N(AbilityState)++; + // fallthrough + case RIDE_STATE_MOUNT_4: if (!(playerStatus->flags & PS_FLAG_HIT_FIRE)) { - npc->pos.x += (npc->moveToPos.x - npc->pos.x) / npc->duration; - npc->pos.z += (npc->moveToPos.z - npc->pos.z) / npc->duration; - npc->pos.y += (npc->moveToPos.y - npc->pos.y) / npc->duration; - playerStatus->position.y += npc->jumpVelocity; - colliderHeightTemp = playerStatus->colliderHeight; - func_802BD99C_3214EC(npc, colliderHeightTemp, (colliderHeightTemp * 2)); - playerStatus->position.y += D_802BFF24; - npc->pos.y += D_802BFF24; - npc->jumpVelocity -= npc->jumpScale; + lakilester->pos.x += (lakilester->moveToPos.x - lakilester->pos.x) / lakilester->duration; + lakilester->pos.z += (lakilester->moveToPos.z - lakilester->pos.z) / lakilester->duration; + lakilester->pos.y += (lakilester->moveToPos.y - lakilester->pos.y) / lakilester->duration; + playerStatus->position.y += lakilester->jumpVelocity; + N(test_mounting_height_adjustment)(lakilester, playerStatus->colliderHeight, 2 * playerStatus->colliderHeight); + playerStatus->position.y += N(MountingDeltaY); + lakilester->pos.y += N(MountingDeltaY); + lakilester->jumpVelocity -= lakilester->jumpScale; - if (npc->jumpVelocity <= 0.0f) { + if (lakilester->jumpVelocity <= 0.0f) { suggest_player_anim_allow_backward(ANIM_Mario1_Fall); } - npc->duration--; + lakilester->duration--; - if (npc->duration > 0) { - if (npc->duration == 1) { - add_vec2D_polar(&npc->pos.x, &npc->pos.z, -2.0f, + if (lakilester->duration > 0) { + if (lakilester->duration == 1) { + add_vec2D_polar(&lakilester->pos.x, &lakilester->pos.z, -2.0f, gCameras[gCurrentCameraID].currentYaw); } } else { - playerStatus->position.y = npc->pos.y + 10.0f; - npc->moveSpeed = playerStatus->runSpeed; - npc->jumpScale = 0.0f; - npc->yaw = playerStatus->targetYaw; - npc->duration = 3; + playerStatus->position.y = lakilester->pos.y + 10.0f; + lakilester->moveSpeed = playerStatus->runSpeed; + lakilester->jumpScale = 0.0f; + lakilester->yaw = playerStatus->targetYaw; + lakilester->duration = 3; set_action_state(ACTION_STATE_RIDE); suggest_player_anim_always_forward(ANIM_MarioW2_RideLaki); disable_player_shadow(); - partnerActionStatus->actingPartner = PARTNER_LAKILESTER; - partnerActionStatus->partnerActionState = PARTNER_ACTION_LAKILESTER_1; + partnerStatus->actingPartner = PARTNER_LAKILESTER; + partnerStatus->partnerActionState = PARTNER_ACTION_LAKILESTER_1; playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED; - gGameStatusPtr->keepUsingPartnerOnMapChange = 0; - D_802BFF18 = 0; - D_802BFF0C = 2; - func_802BFB44_323694(2.0f); - D_802BFF14 = 104; + gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; + N(PlayerBounceOffset) = 0; + N(MountState) = MOUNT_STATE_DONE; + N(offset_player_from_camera)(2.0f); + N(AbilityState) = RIDE_STATE_START_RIDING; playerStatus->animFlags |= PA_FLAG_RIDING_PARTNER; } } else { - D_802BFF14 = 10; + N(AbilityState) = RIDE_STATE_FINISH_1; } break; - case 104: + case RIDE_STATE_START_RIDING: if (playerStatus->flags & PS_FLAG_HIT_FIRE) { - D_802BFF14 = 10; + N(AbilityState) = RIDE_STATE_FINISH_1; + break; + } + lakilester->duration--; + if (lakilester->duration != 0) { + if (partnerStatus->pressedButtons & (BUTTON_B | D_CBUTTONS)) { + if (N(can_dismount)()) { + N(AbilityState) = RIDE_STATE_DISMOUNT_1; + } + } break; } else { - npc->duration--; - if (npc->duration != 0) { - if (partnerActionStatus->pressedButtons & (BUTTON_B | D_CBUTTONS) && lakilester_raycast_below()) { - D_802BFF14 = 3; - } - break; - } else { - D_802BFF14 = 1; - npc->flags |= NPC_FLAG_IGNORE_WORLD_COLLISION; - } + N(AbilityState) = RIDE_STATE_RIDING; + lakilester->flags |= NPC_FLAG_IGNORE_WORLD_COLLISION; } - case 1: - func_802BDDD8_321928(npc); + // fallthrough + case RIDE_STATE_RIDING: + N(update_riding_physics)(lakilester); playerStatus->animFlags |= PA_FLAG_RIDING_PARTNER; - D_802BFF18++; - npc->pos.y = npc->moveToPos.y + 2.0f; + lakilester->pos.y = lakilester->moveToPos.y + 2.0f; - if (D_802BFF18 >= 10) { - D_802BFF18 = D_802BFF18 - 18; + N(PlayerBounceOffset)++; + if (N(PlayerBounceOffset) >= 10) { + N(PlayerBounceOffset) -= 18; } - if (partnerActionStatus->inputDisabled == FALSE) { - playerStatus->targetYaw = npc->yaw; + if (partnerStatus->inputDisabledCount == 0) { + playerStatus->targetYaw = lakilester->yaw; } - - if (!(playerStatus->flags & PS_FLAG_HIT_FIRE)) { - if (partnerActionStatus->pressedButtons & (BUTTON_B | D_CBUTTONS)) { - if (lakilester_raycast_below()) { - D_802BFF14 = 3; - } else { - if (!(playerStatus->animFlags & PA_FLAG_PARTNER_USAGE_STOPPED)) { - sfx_play_sound_at_npc(SOUND_MENU_ERROR, SOUND_SPACE_MODE_0, NPC_PARTNER); - } - playerStatus->animFlags &= ~PA_FLAG_PARTNER_USAGE_STOPPED; - } - } - } else { - D_802BFF14 = 10; + if (playerStatus->flags & PS_FLAG_HIT_FIRE) { + N(AbilityState) = RIDE_STATE_FINISH_1; break; } + if (partnerStatus->pressedButtons & (BUTTON_B | D_CBUTTONS)) { + if (N(can_dismount)()) { + N(AbilityState) = RIDE_STATE_DISMOUNT_1; + } else { + if (!(playerStatus->animFlags & PA_FLAG_FORCED_PARTNER_ABILITY_END)) { + sfx_play_sound_at_npc(SOUND_MENU_ERROR, SOUND_SPACE_MODE_0, NPC_PARTNER); + } + playerStatus->animFlags &= ~PA_FLAG_FORCED_PARTNER_ABILITY_END; + } + } break; - case 3: - npc->flags &= ~NPC_FLAG_IGNORE_WORLD_COLLISION; + case RIDE_STATE_DISMOUNT_1: + lakilester->flags &= ~NPC_FLAG_IGNORE_WORLD_COLLISION; playerStatus->flags |= PS_FLAG_PAUSE_DISABLED; - lakilester_raycast_below(); + N(can_dismount)(); camYaw = camera->currentYaw; if (playerStatus->spriteFacingAngle >= 90.0f && playerStatus->spriteFacingAngle < 270.0f) { yaw = (180.0f + camYaw) - 90.0f; } else { yaw = (0.0f + camYaw) - 90.0f; } - npc->yaw = yaw; - sp2C = dist2D(playerStatus->position.x, playerStatus->position.z, - npc->moveToPos.x, npc->moveToPos.z); - npc->yaw = atan2(playerStatus->position.x, playerStatus->position.z, - npc->moveToPos.x, npc->moveToPos.z); - npc->duration = 14; - npc->jumpScale = 1.2f; + lakilester->yaw = yaw; + dist = dist2D(playerStatus->position.x, playerStatus->position.z, + lakilester->moveToPos.x, lakilester->moveToPos.z); + lakilester->yaw = atan2(playerStatus->position.x, playerStatus->position.z, + lakilester->moveToPos.x, lakilester->moveToPos.z); + lakilester->duration = 14; + lakilester->jumpScale = 1.2f; - if (npc->moveToPos.y > npc->pos.y) { - npc->jumpVelocity = ((npc->moveToPos.y - npc->pos.y) / 14.0f) + 6.0f; + if (lakilester->moveToPos.y > lakilester->pos.y) { + lakilester->jumpVelocity = 6.0f + (lakilester->moveToPos.y - lakilester->pos.y) / 14.0f; } else { - npc->jumpVelocity = 6.0f; + lakilester->jumpVelocity = 6.0f; } - npc->moveSpeed = sp2C / npc->duration; + lakilester->moveSpeed = dist / lakilester->duration; suggest_player_anim_allow_backward(ANIM_Mario1_BeforeJump); - D_802BFF14 += 1; + N(AbilityState)++; break; - case 4: + case RIDE_STATE_DISMOUNT_2: suggest_player_anim_allow_backward(ANIM_Mario1_Jump); - D_802BFF14++; - /* fallthrough */ - case 5: + N(AbilityState)++; + // fallthrough + case RIDE_STATE_DISMOUNT_3: gCameras[CAM_DEFAULT].moveFlags |= CAMERA_MOVE_IGNORE_PLAYER_Y; - playerStatus->position.y += npc->jumpVelocity; - sp2C = playerStatus->colliderHeight * 0.5f; + playerStatus->position.y += lakilester->jumpVelocity; + dist = playerStatus->colliderHeight * 0.5f; x = playerStatus->position.x; y = playerStatus->position.y + (playerStatus->colliderHeight * 0.5f); @@ -837,48 +865,48 @@ API_CALLABLE(LakilesterUseAbility) { yaw = playerStatus->spriteFacingAngle - 90.0f + gCameras[gCurrentCameraID].currentYaw; - if (player_raycast_up_corners(playerStatus, &x, &y, &z, &sp2C, yaw) >= 0) { - D_802BFF14 = 10; + if (player_raycast_up_corners(playerStatus, &x, &y, &z, &dist, yaw) >= 0) { + N(AbilityState) = RIDE_STATE_FINISH_1; break; } - npc->jumpVelocity -= npc->jumpScale; - add_vec2D_polar(&playerStatus->position.x, &playerStatus->position.z, npc->moveSpeed, npc->yaw); + lakilester->jumpVelocity -= lakilester->jumpScale; + add_vec2D_polar(&playerStatus->position.x, &playerStatus->position.z, lakilester->moveSpeed, lakilester->yaw); func_800E4AD8(0); - if (func_802BE6A0_3221F0(&y) >= 0) { - D_802BFF14 = 10; + if (N(test_dismount_height)(&y) > NO_COLLIDER) { + N(AbilityState) = RIDE_STATE_FINISH_1; playerStatus->position.y = y; } break; } gCameras[CAM_DEFAULT].targetPos.x = playerStatus->position.x; - gCameras[CAM_DEFAULT].targetPos.y = npc->moveToPos.y; + gCameras[CAM_DEFAULT].targetPos.y = lakilester->moveToPos.y; gCameras[CAM_DEFAULT].targetPos.z = playerStatus->position.z; - if (D_802BFF14 == 10) { - D_802BFF0C = 0; - npc->flags &= ~(NPC_FLAG_IGNORE_WORLD_COLLISION | NPC_FLAG_TOUCHES_GROUND | NPC_FLAG_8); + if (N(AbilityState) == RIDE_STATE_FINISH_1) { + N(MountState) = MOUNT_STATE_NONE; + lakilester->flags &= ~(NPC_FLAG_IGNORE_WORLD_COLLISION | NPC_FLAG_TOUCHES_GROUND | NPC_FLAG_8); - if (D_802BFF08 != 0) { - D_802BFF08 = 0; + if (N(PlayerCollisionDisabled)) { + N(PlayerCollisionDisabled) = FALSE; enable_player_static_collisions(); } enable_player_shadow(); - gGameStatusPtr->keepUsingPartnerOnMapChange = 0; + gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; if (playerStatus->flags & PS_FLAG_HIT_FIRE) { - partnerActionStatus->actingPartner = PARTNER_NONE; - partnerActionStatus->partnerActionState = PARTNER_ACTION_NONE; + partnerStatus->actingPartner = PARTNER_NONE; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; - if (D_802BFF04 != 0) { - D_802BFF04 = 0; + if (N(LockingPlayerInput)) { + N(LockingPlayerInput) = FALSE; enable_player_input(); } - partner_clear_player_tracking(npc); + partner_clear_player_tracking(lakilester); set_action_state(ACTION_STATE_HIT_FIRE); playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED; return ApiStatus_DONE1; @@ -886,54 +914,54 @@ API_CALLABLE(LakilesterUseAbility) { set_action_state(ACTION_STATE_FALLING); gravity_use_fall_parms(); - D_802BFF14 = 11; + N(AbilityState) = RIDE_STATE_FINISH_2; return ApiStatus_BLOCK; } - - if (D_802BFF14 == 11) { - npc->flags &= ~(NPC_FLAG_IGNORE_WORLD_COLLISION | NPC_FLAG_TOUCHES_GROUND | NPC_FLAG_8); - partnerActionStatus->actingPartner = PARTNER_NONE; - partnerActionStatus->partnerActionState = PARTNER_ACTION_NONE; + + if (N(AbilityState) == RIDE_STATE_FINISH_2) { + lakilester->flags &= ~(NPC_FLAG_IGNORE_WORLD_COLLISION | NPC_FLAG_TOUCHES_GROUND | NPC_FLAG_8); + partnerStatus->actingPartner = PARTNER_NONE; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED; - if (D_802BFF04 != 0) { - D_802BFF04 = 0; + if (N(LockingPlayerInput)) { + N(LockingPlayerInput) = FALSE; enable_player_input(); } - gGameStatusPtr->keepUsingPartnerOnMapChange = 0; - partner_clear_player_tracking(npc); + gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; + partner_clear_player_tracking(lakilester); func_800EF3D4(2); return ApiStatus_DONE1; } + return ApiStatus_BLOCK; } - EvtScript EVS_WorldLakilester_UseAbility = { - EVT_CALL(LakilesterUseAbility) + EVT_CALL(N(UseAbility)) EVT_RETURN EVT_END }; -API_CALLABLE(func_802BF4F0_323040) { +API_CALLABLE(N(PutAway)) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; Camera* cam = &gCameras[CAM_DEFAULT]; Npc* lakilester = script->owner2.npc; f32 sp20, sp24, sp28, sp2C; f32 yaw; if (isInitialCall) { - D_802BFF00 = (D_802BFF0C == 0) ? 3 : 0; + N(PutAwayState) = (N(MountState) == MOUNT_STATE_NONE) ? PUT_AWAY_FINISH_1 : PUT_AWAY_DISMOUNT_1; partner_init_put_away(lakilester); - lakilester_raycast_below(); + N(can_dismount)(); playerStatus->animFlags &= ~PA_FLAG_RIDING_PARTNER; playerStatus->flags |= PS_FLAG_PAUSE_DISABLED; } - switch (D_802BFF00) { - case 0: - lakilester_raycast_below(); + switch (N(PutAwayState)) { + case PUT_AWAY_DISMOUNT_1: + N(can_dismount)(); yaw = cam->currentYaw; if ((playerStatus->spriteFacingAngle >= 90.0f) && (playerStatus->spriteFacingAngle < 270.0f)) { lakilester->yaw = (yaw + 180.0f) - 90.0f; @@ -955,12 +983,12 @@ API_CALLABLE(func_802BF4F0_323040) { lakilester->yaw = atan2(playerStatus->position.x, playerStatus->position.z, lakilester->moveToPos.x, lakilester->moveToPos.z); suggest_player_anim_allow_backward(ANIM_Mario1_BeforeJump); - D_802BFF00++; + N(PutAwayState)++; break; - case 1: + case PUT_AWAY_DISMOUNT_2: suggest_player_anim_allow_backward(ANIM_Mario1_Jump); - D_802BFF00++; - case 2: + N(PutAwayState)++; + case PUT_AWAY_DISMOUNT_3: playerStatus->position.y += lakilester->jumpVelocity; lakilester->jumpVelocity -= lakilester->jumpScale; add_vec2D_polar(&playerStatus->position.x, &playerStatus->position.z, @@ -979,7 +1007,7 @@ API_CALLABLE(func_802BF4F0_323040) { if (npc_raycast_down_around(0, &sp20, &sp24, &sp28, &sp2C, lakilester->yaw, lakilester->collisionRadius)) { - D_802BFF00 = 3; + N(PutAwayState) = PUT_AWAY_FINISH_1; playerStatus->position.y = sp24; } break; @@ -989,113 +1017,113 @@ API_CALLABLE(func_802BF4F0_323040) { gCameras[CAM_DEFAULT].targetPos.y = playerStatus->position.y; gCameras[CAM_DEFAULT].targetPos.z = playerStatus->position.z; - switch (D_802BFF00) { - case 3: + switch (N(PutAwayState)) { + case PUT_AWAY_FINISH_1: lakilester->flags &= ~(NPC_FLAG_IGNORE_WORLD_COLLISION | NPC_FLAG_8); - if (D_802BFF08) { - D_802BFF08 = FALSE; + if (N(PlayerCollisionDisabled)) { + N(PlayerCollisionDisabled) = FALSE; enable_player_static_collisions(); } enable_player_shadow(); if (playerStatus->flags & PS_FLAG_HIT_FIRE) { - partnerActionStatus->actingPartner = PARTNER_NONE; - partnerActionStatus->partnerActionState = PARTNER_ACTION_NONE; - if (D_802BFF04) { - D_802BFF04 = FALSE; + partnerStatus->actingPartner = PARTNER_NONE; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; + if (N(LockingPlayerInput)) { + N(LockingPlayerInput) = FALSE; enable_player_input(); } - gGameStatusPtr->keepUsingPartnerOnMapChange = 0; - D_802BFF0C = 0; + gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; + N(MountState) = MOUNT_STATE_NONE; partner_clear_player_tracking(lakilester); set_action_state(ACTION_STATE_HIT_FIRE); return ApiStatus_DONE1; } - if (D_802BFF0C == 0) { + if (N(MountState) == MOUNT_STATE_NONE) { phys_main_collision_below(); } else { set_action_state(ACTION_STATE_FALLING); gravity_use_fall_parms(); } - D_802BFF00++; + N(PutAwayState)++; break; - case 4: - partnerActionStatus->actingPartner = PARTNER_NONE; - partnerActionStatus->partnerActionState = PARTNER_ACTION_NONE; + case PUT_AWAY_FINISH_2: + partnerStatus->actingPartner = PARTNER_NONE; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED; - if (D_802BFF04) { - D_802BFF04 = FALSE; + if (N(LockingPlayerInput)) { + N(LockingPlayerInput) = FALSE; enable_player_input(); } - gGameStatusPtr->keepUsingPartnerOnMapChange = 0; - D_802BFF0C = 0; + gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; + N(MountState) = MOUNT_STATE_NONE; partner_clear_player_tracking(lakilester); - D_802BFF00++; + N(PutAwayState)++; break; - case 5: - if (partner_put_away(lakilester) == FALSE) { - break; + case PUT_AWAY_FINISH_3: + if (partner_put_away(lakilester)) { + return ApiStatus_DONE1; } - return ApiStatus_DONE1; + break; } return ApiStatus_BLOCK; } EvtScript EVS_WorldLakilester_PutAway = { - EVT_CALL(func_802BF4F0_323040) + EVT_CALL(N(PutAway)) EVT_RETURN EVT_END }; -void world_lakilester_pre_battle(Npc* npc) { - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; +void N(pre_battle)(Npc* lakilester) { + PartnerStatus* partnerStatus = &gPartnerStatus; - if (D_802BFF0C) { - partnerActionStatus->npc = *npc; - partnerActionStatus->partnerAction_unk_1 = TRUE; + if (N(MountState) != MOUNT_STATE_NONE) { + partnerStatus->npc = *lakilester; + partnerStatus->shouldResumeAbility = TRUE; enable_player_static_collisions(); enable_player_input(); set_action_state(ACTION_STATE_IDLE); - partner_clear_player_tracking(npc); + partner_clear_player_tracking(lakilester); } - partnerActionStatus->actingPartner = PARTNER_LAKILESTER; - D_802BFF18 = 0; + partnerStatus->actingPartner = PARTNER_LAKILESTER; + N(PlayerBounceOffset) = 0; } -void world_lakilester_post_battle(Npc* npc) { - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; +void N(post_battle)(Npc* lakilester) { + PartnerStatus* partnerStatus = &gPartnerStatus; - if (partnerActionStatus->partnerAction_unk_1) { - if (D_802BFF0C) { - *npc = partnerActionStatus->npc; - gGameStatusPtr->keepUsingPartnerOnMapChange = 1; + if (partnerStatus->shouldResumeAbility) { + if (N(MountState) != MOUNT_STATE_NONE) { + *lakilester = partnerStatus->npc; + gGameStatusPtr->keepUsingPartnerOnMapChange = TRUE; set_action_state(ACTION_STATE_RIDE); - partnerActionStatus->actingPartner = PARTNER_NONE; - partnerActionStatus->partnerActionState = PARTNER_ACTION_NONE; + partnerStatus->actingPartner = PARTNER_NONE; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; disable_player_input(); partner_use_ability(); } } } -void func_802BFB44_323694(f32 arg0) { +void N(offset_player_from_camera)(f32 speed) { Camera* currentCamera = &gCameras[gCurrentCameraID]; PlayerStatus* playerStatus = &gPlayerStatus; - add_vec2D_polar(&playerStatus->position.x, &playerStatus->position.z, arg0, currentCamera->currentYaw); + add_vec2D_polar(&playerStatus->position.x, &playerStatus->position.z, speed, currentCamera->currentYaw); } -API_CALLABLE(func_802BFBA0_3236F0) { - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; +API_CALLABLE(N(EnterMap)) { + PartnerStatus* partnerStatus = &gPartnerStatus; PlayerStatus* playerStatus = &gPlayerStatus; - Npc* npc = get_npc_unsafe(NPC_PARTNER); + Npc* lakilester = get_npc_unsafe(NPC_PARTNER); f32 temp_f0, temp_f2, temp_f4; f32* temp_s0_2; s32 temp_v0_2; @@ -1106,34 +1134,34 @@ API_CALLABLE(func_802BFBA0_3236F0) { switch (script->functionTemp[0]) { case 0: - if (script->varTable[12] == 0) { + if (!script->varTable[12]) { temp_f0 = playerStatus->position.x; - npc->pos.x = temp_f0; - npc->moveToPos.x = temp_f0; + lakilester->pos.x = temp_f0; + lakilester->moveToPos.x = temp_f0; temp_f4 = playerStatus->position.z; - npc->pos.z = temp_f4; - npc->moveToPos.z = temp_f4; - playerStatus->position.y = npc->pos.y + 10.0f; + lakilester->pos.z = temp_f4; + lakilester->moveToPos.z = temp_f4; + playerStatus->position.y = lakilester->pos.y + 10.0f; partner_kill_ability_script(); } else { set_action_state(ACTION_STATE_RIDE); disable_player_static_collisions(); disable_player_input(); - npc->moveToPos.x = npc->pos.x = playerStatus->position.x; - npc->moveToPos.y = npc->pos.y = playerStatus->position.y; - npc->moveToPos.z = npc->pos.z = playerStatus->position.z; - playerStatus->position.y = npc->pos.y + 10.0f; + lakilester->moveToPos.x = lakilester->pos.x = playerStatus->position.x; + lakilester->moveToPos.y = lakilester->pos.y = playerStatus->position.y; + lakilester->moveToPos.z = lakilester->pos.z = playerStatus->position.z; + playerStatus->position.y = lakilester->pos.y + 10.0f; } script->functionTemp[1] = script->varTable[4]; temp_s0_2 = (f32*)&script->varTable[5]; - temp_f2 = atan2(npc->pos.x, npc->pos.z, script->varTable[1], script->varTable[3]); - npc->yaw = temp_f2; + temp_f2 = atan2(lakilester->pos.x, lakilester->pos.z, script->varTable[1], script->varTable[3]); + lakilester->yaw = temp_f2; - if (script->varTable[12] != 0) { + if (script->varTable[12]) { if (temp_f2 >= 0.0f && temp_f2 <= 180.0f) { - npc->yawCamOffset = temp_f2; - npc->isFacingAway = 1; + lakilester->yawCamOffset = temp_f2; + lakilester->isFacingAway = TRUE; } } @@ -1141,31 +1169,31 @@ API_CALLABLE(func_802BFBA0_3236F0) { playerStatus->anim = ANIM_MarioW2_RideLaki; playerStatus->animNotifyValue = 0; playerStatus->flags |= PS_FLAG_FACE_FORWARDS; - func_802BFB44_323694(2.0f); - gGameStatusPtr->keepUsingPartnerOnMapChange = 1; - npc->flags |= NPC_FLAG_IGNORE_PLAYER_COLLISION; - npc->moveSpeed = *temp_s0_2; - npc->jumpScale = 0.0f; - D_802BFF10 = 0; - D_802BFF18 = 0; + N(offset_player_from_camera)(2.0f); + gGameStatusPtr->keepUsingPartnerOnMapChange = TRUE; + lakilester->flags |= NPC_FLAG_IGNORE_PLAYER_COLLISION; + lakilester->moveSpeed = *temp_s0_2; + lakilester->jumpScale = 0.0f; + N(UpdatePushingWall) = FALSE; + N(PlayerBounceOffset) = 0; script->functionTemp[0] = 1; break; case 1: - npc_move_heading(npc, npc->moveSpeed, npc->yaw); - playerStatus->position.x = npc->pos.x; - playerStatus->position.y = npc->pos.y + 10.0f; - playerStatus->position.z = npc->pos.z; - playerStatus->targetYaw = npc->yaw; - func_802BFB44_323694(2.0f); + npc_move_heading(lakilester, lakilester->moveSpeed, lakilester->yaw); + playerStatus->position.x = lakilester->pos.x; + playerStatus->position.y = lakilester->pos.y + 10.0f; + playerStatus->position.z = lakilester->pos.z; + playerStatus->targetYaw = lakilester->yaw; + N(offset_player_from_camera)(2.0f); script->functionTemp[1] -= 1; if (script->functionTemp[1] == 0) { - if (script->varTable[12] != 0) { - partnerActionStatus->partnerAction_unk_1 = TRUE; + if (script->varTable[12]) { + partnerStatus->shouldResumeAbility = TRUE; set_action_state(ACTION_STATE_RIDE); - partnerActionStatus->actingPartner = PARTNER_NONE; - partnerActionStatus->partnerActionState = PARTNER_ACTION_NONE; + partnerStatus->actingPartner = PARTNER_NONE; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; partner_use_ability(); enable_player_static_collisions(); enable_player_input(); @@ -1177,8 +1205,8 @@ API_CALLABLE(func_802BFBA0_3236F0) { return ApiStatus_BLOCK; } -EvtScript evs_worldlakilester_riding = { - EVT_CALL(func_802BFBA0_3236F0) +EvtScript EVS_WorldLakilester_EnterMap = { + EVT_CALL(N(EnterMap)) EVT_RETURN EVT_END }; diff --git a/src/world/partner/lakilester.h b/src/world/partner/lakilester.h index 51a409fcb0..c01dee63e7 100644 --- a/src/world/partner/lakilester.h +++ b/src/world/partner/lakilester.h @@ -8,10 +8,13 @@ void world_lakilester_init(Npc*); void world_lakilester_pre_battle(Npc*); void world_lakilester_post_battle(Npc*); +void world_lakilester_sync_player_position(void); +s32 world_lakilester_can_dismount(void); + extern EvtScript EVS_WorldLakilester_TakeOut; extern EvtScript EVS_WorldLakilester_Update; extern EvtScript EVS_WorldLakilester_UseAbility; extern EvtScript EVS_WorldLakilester_PutAway; -extern EvtScript evs_worldlakilester_riding; +extern EvtScript EVS_WorldLakilester_EnterMap; #endif diff --git a/src/world/partner/parakarry.c b/src/world/partner/parakarry.c index d2faf00369..5166317e3b 100644 --- a/src/world/partner/parakarry.c +++ b/src/world/partner/parakarry.c @@ -8,22 +8,22 @@ BSS b32 N(UsingAbility); BSS b32 N(LockingPlayerInput); BSS b32 N(PlayerCollisionDisabled); // minor bug: never gets properly reset to FALSE BSS b32 N(PlayerWasFacingLeft); -BSS s32 N(UseAbilityState); +BSS s32 N(AbilityState); BSS s32 N(AbilityStateTime); BSS TweesterPhysics N(TweesterPhysicsData); enum { - AIR_LIFT_NONE = 0, // only used for initial value + AIR_LIFT_NONE = 0, // only used for initial value // next two states lock input for a few frames, during which the ability can be canceled AIR_LIFT_INIT = 40, AIR_LIFT_DELAY = 41, AIR_LIFT_BEGIN = 30, AIR_LIFT_GATHER = 31, - AIR_LIFT_PICKUP = 1, // pick up the player and lift them into the air - AIR_LIFT_CARRY = 2, // carry the player through the air - AIR_LIFT_HOLD = 6, // remain in one position for a short period of time - AIR_LIFT_JUMP = 20, // player jumped off while being carried - AIR_LIFT_DROP = 21, // dropping the player + AIR_LIFT_PICKUP = 1, // pick up the player and lift them into the air + AIR_LIFT_CARRY = 2, // carry the player through the air + AIR_LIFT_HOLD = 6, // remain in one position for a short period of time + AIR_LIFT_JUMP = 20, // player jumped off while being carried + AIR_LIFT_DROP = 21, // dropping the player AIR_LIFT_CANCEL = 22, }; @@ -31,7 +31,7 @@ void N(init)(Npc* parakarry) { parakarry->collisionHeight = 37; parakarry->collisionRadius = 40; N(UsingAbility) = FALSE; - N(UseAbilityState) = AIR_LIFT_NONE; + N(AbilityState) = AIR_LIFT_NONE; N(LockingPlayerInput) = FALSE; N(PlayerCollisionDisabled) = FALSE; N(PlayerWasFacingLeft) = FALSE; @@ -176,7 +176,7 @@ s32 N(update_current_floor)(void) { if (surfaceType == SURFACE_TYPE_SPIKES || surfaceType == SURFACE_TYPE_LAVA) { gPlayerStatus.hazardType = HAZARD_TYPE_SPIKES; gPlayerStatus.flags |= PS_FLAG_HIT_FIRE; - N(UseAbilityState) = AIR_LIFT_DROP; + N(AbilityState) = AIR_LIFT_DROP; } return hitResult; @@ -184,7 +184,7 @@ s32 N(update_current_floor)(void) { API_CALLABLE(N(UseAbility)) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; Npc* parakarry = script->owner2.npc; s32 buttonTemp = BUTTON_A; f32 x, y, z, yaw, length; @@ -204,34 +204,34 @@ API_CALLABLE(N(UseAbility)) { return ApiStatus_DONE2; } - if (!partnerActionStatus->partnerAction_unk_1) { + if (!partnerStatus->shouldResumeAbility) { if (!func_800EA52C(PARTNER_PARAKARRY)) { return ApiStatus_DONE2; } - N(UseAbilityState) = AIR_LIFT_INIT; + N(AbilityState) = AIR_LIFT_INIT; parakarry->flags &= ~NPC_FLAG_COLLDING_FORWARD_WITH_WORLD; parakarry->flags |= NPC_FLAG_COLLDING_WITH_WORLD; } else { - partnerActionStatus->partnerAction_unk_1 = FALSE; + partnerStatus->shouldResumeAbility = FALSE; set_action_state(ACTION_STATE_RIDE); parakarry->flags &= ~(NPC_FLAG_JUMPING | NPC_FLAG_GRAVITY); N(UsingAbility) = TRUE; gCameras[CAM_DEFAULT].moveFlags |= CAMERA_MOVE_IGNORE_PLAYER_Y; parakarry->currentAnim = ANIM_WorldParakarry_CarryLight; - partnerActionStatus->actingPartner = PARTNER_PARAKARRY; - partnerActionStatus->partnerActionState = PARTNER_ACTION_PARAKARRY_HOVER; + partnerStatus->actingPartner = PARTNER_PARAKARRY; + partnerStatus->partnerActionState = PARTNER_ACTION_PARAKARRY_HOVER; parakarry->flags &= ~NPC_FLAG_COLLDING_FORWARD_WITH_WORLD; parakarry->flags |= NPC_FLAG_COLLDING_WITH_WORLD; } } - switch (N(UseAbilityState)) { + switch (N(AbilityState)) { case AIR_LIFT_INIT: if (playerStatus->inputDisabledCount != 0) { return ApiStatus_DONE2; } N(AbilityStateTime) = 3; - N(UseAbilityState) = AIR_LIFT_DELAY; + N(AbilityState) = AIR_LIFT_DELAY; script->functionTemp[2] = playerStatus->inputDisabledCount; // fallthrough case AIR_LIFT_DELAY: @@ -239,14 +239,14 @@ API_CALLABLE(N(UseAbility)) { if (script->functionTemp[2] < playerStatus->inputDisabledCount || !func_800EA52C(PARTNER_PARAKARRY)) { return ApiStatus_DONE2; } - N(UseAbilityState) = AIR_LIFT_BEGIN; + N(AbilityState) = AIR_LIFT_BEGIN; } else { N(AbilityStateTime)--; } break; } - switch (N(UseAbilityState)) { + switch (N(AbilityState)) { case AIR_LIFT_BEGIN: set_action_state(ACTION_STATE_RIDE); disable_player_input(); @@ -258,13 +258,13 @@ API_CALLABLE(N(UseAbility)) { gCameras[CAM_DEFAULT].moveFlags |= CAMERA_MOVE_IGNORE_PLAYER_Y; parakarry->flags &= ~(NPC_FLAG_JUMPING | NPC_FLAG_GRAVITY); parakarry->flags |= NPC_FLAG_IGNORE_WORLD_COLLISION | NPC_FLAG_8; - partnerActionStatus->actingPartner = PARTNER_PARAKARRY; - partnerActionStatus->partnerActionState = PARTNER_ACTION_PARAKARRY_HOVER; + partnerStatus->actingPartner = PARTNER_PARAKARRY; + partnerStatus->partnerActionState = PARTNER_ACTION_PARAKARRY_HOVER; N(PlayerWasFacingLeft) = partner_force_player_flip_done(); enable_npc_blur(parakarry); parakarry->yaw = atan2(parakarry->pos.x, parakarry->pos.z, playerStatus->position.x, playerStatus->position.z); parakarry->duration = 4; - N(UseAbilityState)++; // AIR_LIFT_GATHER + N(AbilityState)++; // AIR_LIFT_GATHER break; case AIR_LIFT_GATHER: if (playerStatus->actionState == ACTION_STATE_HIT_FIRE @@ -274,7 +274,7 @@ API_CALLABLE(N(UseAbility)) { || playerStatus->actionState == ACTION_STATE_HOP ) { disable_npc_blur(parakarry); - N(UseAbilityState) = AIR_LIFT_DROP; + N(AbilityState) = AIR_LIFT_DROP; } else { suggest_player_anim_allow_backward(ANIM_Mario1_Idle); parakarry->moveToPos.x = playerStatus->position.x; @@ -295,7 +295,7 @@ API_CALLABLE(N(UseAbility)) { if (parakarry->duration != 0) { if (script->functionTemp[2] < playerStatus->inputDisabledCount) { disable_npc_blur(parakarry); - N(UseAbilityState) = AIR_LIFT_CANCEL; + N(AbilityState) = AIR_LIFT_CANCEL; } } else { disable_npc_blur(parakarry); @@ -309,7 +309,7 @@ API_CALLABLE(N(UseAbility)) { gCollisionStatus.currentFloor = NO_COLLIDER; parakarry->currentFloor = NO_COLLIDER; N(AbilityStateTime) = 20; - N(UseAbilityState) = AIR_LIFT_PICKUP; + N(AbilityState) = AIR_LIFT_PICKUP; } } break; @@ -318,12 +318,12 @@ API_CALLABLE(N(UseAbility)) { || playerStatus->actionState == ACTION_STATE_HIT_LAVA || playerStatus->actionState == ACTION_STATE_KNOCKBACK ) { - N(UseAbilityState) = AIR_LIFT_DROP; + N(AbilityState) = AIR_LIFT_DROP; break; } // handle jump/cancel inputs - if (partnerActionStatus->pressedButtons & (BUTTON_A | BUTTON_B | BUTTON_C_DOWN)) { - N(UseAbilityState) = (partnerActionStatus->pressedButtons & BUTTON_A) ? AIR_LIFT_JUMP : AIR_LIFT_DROP; + if (partnerStatus->pressedButtons & (BUTTON_A | BUTTON_B | BUTTON_C_DOWN)) { + N(AbilityState) = (partnerStatus->pressedButtons & BUTTON_A) ? AIR_LIFT_JUMP : AIR_LIFT_DROP; suggest_player_anim_allow_backward(ANIM_Mario1_Idle); break; } @@ -354,7 +354,7 @@ API_CALLABLE(N(UseAbility)) { halfCollisionHeight = playerStatus->spriteFacingAngle - 90.0f + gCameras[gCurrentCameraID].currentYaw; if (player_raycast_up_corners(playerStatus, &x, &y, &z, &length, halfCollisionHeight) >= 0) { suggest_player_anim_allow_backward(ANIM_Mario1_Idle); - N(UseAbilityState) = AIR_LIFT_DROP; + N(AbilityState) = AIR_LIFT_DROP; break; } @@ -409,7 +409,7 @@ API_CALLABLE(N(UseAbility)) { if (surfaceType == SURFACE_TYPE_SPIKES || surfaceType == SURFACE_TYPE_LAVA) { playerStatus->hazardType = HAZARD_TYPE_SPIKES; playerStatus->flags |= PS_FLAG_HIT_FIRE; - N(UseAbilityState) = AIR_LIFT_DROP; + N(AbilityState) = AIR_LIFT_DROP; } playerStatus->position.y += (y - playerStatus->position.y) / 4.0f; @@ -418,7 +418,7 @@ API_CALLABLE(N(UseAbility)) { if (parakarry->flags & NPC_FLAG_COLLDING_FORWARD_WITH_WORLD) { suggest_player_anim_allow_backward(ANIM_Mario1_Idle); - N(UseAbilityState) = AIR_LIFT_DROP; + N(AbilityState) = AIR_LIFT_DROP; break; } @@ -435,7 +435,7 @@ API_CALLABLE(N(UseAbility)) { parakarry->currentAnim = ANIM_WorldParakarry_CarryHeavy; parakarry->animationSpeed = 1.8f; gCollisionStatus.currentFloor = NO_COLLIDER; - N(UseAbilityState)++; // AIR_LIFT_CARRY + N(AbilityState)++; // AIR_LIFT_CARRY } break; case AIR_LIFT_CARRY: @@ -444,24 +444,24 @@ API_CALLABLE(N(UseAbility)) { || playerStatus->actionState == ACTION_STATE_HIT_LAVA || playerStatus->actionState == ACTION_STATE_KNOCKBACK ) { - N(UseAbilityState) = AIR_LIFT_DROP; + N(AbilityState) = AIR_LIFT_DROP; break; } suggest_player_anim_always_forward(ANIM_MarioW2_HoldOnto); if (playerStatus->flags & PS_FLAG_HIT_FIRE) { - N(UseAbilityState) = AIR_LIFT_JUMP; + N(AbilityState) = AIR_LIFT_JUMP; break; } // handle jump/cancel inputs - if (partnerActionStatus->pressedButtons & (BUTTON_A | BUTTON_B | BUTTON_C_DOWN)) { - if (partnerActionStatus->pressedButtons & buttonTemp) { // TODO find a way to remove this while still loading 0x15 instead of moving it from register + if (partnerStatus->pressedButtons & (BUTTON_A | BUTTON_B | BUTTON_C_DOWN)) { + if (partnerStatus->pressedButtons & buttonTemp) { // TODO find a way to remove this while still loading 0x15 instead of moving it from register if (!parakarry->pos.x) { } } - N(UseAbilityState) = (partnerActionStatus->pressedButtons & BUTTON_A) ? AIR_LIFT_JUMP : AIR_LIFT_DROP; + N(AbilityState) = (partnerStatus->pressedButtons & BUTTON_A) ? AIR_LIFT_JUMP : AIR_LIFT_DROP; break; } @@ -501,7 +501,7 @@ API_CALLABLE(N(UseAbility)) { playerStatus->colliderHeight, playerStatus->colliderDiameter) ) { suggest_player_anim_allow_backward(ANIM_Mario1_Idle); - N(UseAbilityState) = AIR_LIFT_DROP; + N(AbilityState) = AIR_LIFT_DROP; break; } @@ -538,7 +538,7 @@ API_CALLABLE(N(UseAbility)) { parakarry->pos.y = y; if (hitAbove) { - N(UseAbilityState) = AIR_LIFT_DROP; + N(AbilityState) = AIR_LIFT_DROP; break; } } @@ -553,7 +553,7 @@ API_CALLABLE(N(UseAbility)) { parakarry->duration++; if (!(parakarry->planarFlyDist < 100.0f)) { N(AbilityStateTime) = 5; - N(UseAbilityState) = AIR_LIFT_HOLD; + N(AbilityState) = AIR_LIFT_HOLD; } break; } @@ -561,20 +561,20 @@ API_CALLABLE(N(UseAbility)) { } } suggest_player_anim_allow_backward(ANIM_Mario1_Idle); - N(UseAbilityState) = AIR_LIFT_DROP; + N(AbilityState) = AIR_LIFT_DROP; break; case AIR_LIFT_HOLD: if (N(AbilityStateTime) != 0) { N(AbilityStateTime)--; } else { - N(UseAbilityState) = AIR_LIFT_DROP; + N(AbilityState) = AIR_LIFT_DROP; } break; } - if (N(UseAbilityState) == AIR_LIFT_JUMP - || N(UseAbilityState) == AIR_LIFT_DROP - || N(UseAbilityState) == AIR_LIFT_CANCEL + if (N(AbilityState) == AIR_LIFT_JUMP + || N(AbilityState) == AIR_LIFT_DROP + || N(AbilityState) == AIR_LIFT_CANCEL ) { parakarry->currentAnim = ANIM_WorldParakarry_Idle; N(UsingAbility) = FALSE; @@ -582,8 +582,8 @@ API_CALLABLE(N(UseAbility)) { parakarry->flags &= ~NPC_FLAG_JUMPING; parakarry->animationSpeed = 1.0f; partner_clear_player_tracking(parakarry); - partnerActionStatus->actingPartner = PARTNER_NONE; - partnerActionStatus->partnerActionState = PARTNER_ACTION_NONE; + partnerStatus->actingPartner = PARTNER_NONE; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; enable_partner_ai(); sfx_stop_sound(SOUND_2009); if (N(LockingPlayerInput)) { @@ -594,9 +594,9 @@ API_CALLABLE(N(UseAbility)) { } if ((playerStatus->flags & PS_FLAG_HIT_FIRE)) { set_action_state(ACTION_STATE_HIT_LAVA); - } else if (N(UseAbilityState) == AIR_LIFT_JUMP) { + } else if (N(AbilityState) == AIR_LIFT_JUMP) { start_bounce_b(); - } else if (N(UseAbilityState) == AIR_LIFT_DROP) { + } else if (N(AbilityState) == AIR_LIFT_DROP) { start_falling(); gravity_use_fall_parms(); playerStatus->flags |= PS_FLAG_SCRIPTED_FALL; @@ -636,7 +636,7 @@ EvtScript EVS_WorldParakarry_PutAway = { }; void N(pre_battle)(Npc* parakarry) { - PartnerActionStatus* partnerStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; if (N(UsingAbility)) { if (N(PlayerCollisionDisabled)) { @@ -649,7 +649,7 @@ void N(pre_battle)(Npc* parakarry) { set_action_state(ACTION_STATE_IDLE); partnerStatus->npc = *parakarry; - partnerStatus->partnerAction_unk_1 = TRUE; + partnerStatus->shouldResumeAbility = TRUE; partner_clear_player_tracking(parakarry); } @@ -657,9 +657,9 @@ void N(pre_battle)(Npc* parakarry) { } void N(post_battle)(Npc* parakarry) { - PartnerActionStatus* partnerStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; - if (partnerStatus->partnerAction_unk_1) { + if (partnerStatus->shouldResumeAbility) { if (N(PlayerCollisionDisabled)) { disable_player_static_collisions(); } diff --git a/src/world/partner/sushie.c b/src/world/partner/sushie.c index 6abc1d5929..e1579aa559 100644 --- a/src/world/partner/sushie.c +++ b/src/world/partner/sushie.c @@ -7,32 +7,39 @@ #define NAMESPACE world_sushie -BSS f32 OriginalPlayerY; -BSS s32 bss_802BFEE4; -BSS s32 bss_802BFEE8; -BSS s32 bss_802BFEEC; -BSS s32 bss_802BFEF0; -BSS s32 bss_802BFEF4; -BSS f32 bss_802BFEF8; -BSS f32 bss_802BFEFC; -BSS f32 bss_802BFF00; -BSS f32 bss_802BFF04; -BSS f32 bss_802BFF08; -BSS s32 bss_802BFF0C; -BSS TweesterPhysics SushieTweesterPhysics; +BSS f32 N(WaterSurfaceY); +BSS s32 N(DiveState); +BSS s32 N(DiveTime); +BSS b32 N(IsRiding); +BSS s32 N(TouchDockTime); +BSS b32 N(IsUnderwater); +BSS f32 N(InertialMoveSpeed); +BSS f32 N(InertialMoveAngle); +BSS f32 N(UnusedMoveX); +BSS f32 N(UnusedMoveZ); +BSS f32 N(ResurfaceVelY); +BSS s32 N(bss_802BFF0C); // unused (padding?) +BSS TweesterPhysics N(TweesterPhysicsData); -f32 D_802BFDB0_320B20 = 0.0f; -f32 D_802BFDB4_320B24 = 0.0f; -f32 D_802BFDB8_320B28 = 0.0f; -f32 D_802BFDBC_320B2C = 0.0f; +enum { + DIVE_STATE_NONE = 0, + DIVE_STATE_DELAY = 1, + DIVE_STATE_DIVING = 2, + DIVE_STATE_SURFACING = 3, +}; -void func_802BF920_320690(Npc* sushie); +f32 N(InputStickX) = 0.0f; +f32 N(InputStickY) = 0.0f; +f32 N(InertialStickX) = 0.0f; +f32 N(InertialStickY) = 0.0f; -void func_802BD100_31DE70(void) { +void N(try_cancel_tweester)(Npc* sushie); + +void N(sync_player_position)(void) { Npc* partnerNPC = get_npc_unsafe(NPC_PARTNER); PlayerStatus* playerStatus = &gPlayerStatus; Camera* camera = &gCameras[CAM_DEFAULT]; - s32 phi_v1; + s32 angleOffset; playerStatus->position.x = partnerNPC->pos.x; playerStatus->position.y = partnerNPC->pos.y + 16.0f; @@ -40,281 +47,297 @@ void func_802BD100_31DE70(void) { playerStatus->targetYaw = partnerNPC->yaw; if (playerStatus->spriteFacingAngle < 90.0f || playerStatus->spriteFacingAngle > 270.0f) { - phi_v1 = -8; + angleOffset = -8; } else { - phi_v1 = 8; + angleOffset = 8; } playerStatus->position.z -= cos_rad(DEG_TO_RAD( - camera->currentYaw + playerStatus->spriteFacingAngle - 90.0f + phi_v1)) * -4.0f; + camera->currentYaw + playerStatus->spriteFacingAngle - 90.0f + angleOffset)) * -4.0f; } -void func_802BD20C_31DF7C(f32* arg0, f32* arg1) { - f32 temp_f22; - f32 phi_f20; - f32 stickY = gPartnerActionStatus.stickY; - f32 stickX = gPartnerActionStatus.stickX; +void N(get_movement_from_input)(f32* outAngle, f32* outSpeed) { + f32 moveAngle; + f32 moveSpeed; + f32 stickY = gPartnerStatus.stickY; + f32 stickX = gPartnerStatus.stickX; - D_802BFDB0_320B20 = stickX; - D_802BFDB4_320B24 = stickY; - temp_f22 = clamp_angle(atan2(0.0f, 0.0f, stickX, -stickY) + gCameras[CAM_DEFAULT].currentYaw); - phi_f20 = 0.0f; + N(InputStickX) = stickX; + N(InputStickY) = stickY; + moveAngle = clamp_angle(atan2(0.0f, 0.0f, stickX, -stickY) + gCameras[CAM_DEFAULT].currentYaw); + moveSpeed = 0.0f; - if (dist2D(0.0f, 0.0f, D_802BFDB0_320B20, -D_802BFDB4_320B24) >= 1.0) { - if (SQ(D_802BFDB0_320B20) + SQ(D_802BFDB4_320B24) > 3025.0f) { - if (bss_802BFEE4) { - phi_f20 = 2.0f; + if (dist2D(0.0f, 0.0f, N(InputStickX), -N(InputStickY)) >= 1.0) { + if (SQ(N(InputStickX)) + SQ(N(InputStickY)) > SQ(55)) { + if (N(DiveState) != DIVE_STATE_NONE) { + moveSpeed = 2.0f; } else { - phi_f20 = 4.0f; + moveSpeed = 4.0f; } } else { - phi_f20 = 2.0f; + moveSpeed = 2.0f; } } - *arg0 = temp_f22; - *arg1 = phi_f20; + *outAngle = moveAngle; + *outSpeed = moveSpeed; } -void func_802BD368_31E0D8(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5) { +void N(test_for_water_level)(s32 ignoreFlags, f32 posX, f32 posY, f32 posZ, f32 yaw, f32 radius) { CollisionStatus* collisionStatus = &gCollisionStatus; - f32 sp20; + f32 depth; - arg2 += 100.0f; - sp20 = 200.0f; + posY += 100.0f; + depth = 200.0f; - if (npc_raycast_down_around(arg0, &arg1, &arg2, &arg3, &sp20, arg4, arg5) == 0) { + if (!npc_raycast_down_around(ignoreFlags, &posX, &posY, &posZ, &depth, yaw, radius)) { collisionStatus->currentFloor = NO_COLLIDER; } else { collisionStatus->currentFloor = NpcHitQueryColliderID; - OriginalPlayerY = arg2; + N(WaterSurfaceY) = posY; } } -void func_802BD414_31E184(Npc* npc) { +void N(update_riding_physics)(Npc* sushie) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; CollisionStatus* collisionStatus = &gCollisionStatus; - f32 var_f20; - f32 sp20; - f32 sp24; - f32 sinTheta, cosTheta; + f32 moveSpeedDamping; + f32 moveAngle, moveSpeed; + f32 sinAngle, cosAngle; f32 x, y, z; - f32 sp3C; + f32 depth; - func_802BD20C_31DF7C(&sp20, &sp24); - if (bss_802BFEE4 != 0) { - var_f20 = 80.0f; + // PART 1: + // determine movement speed and direction from input and inertia + + N(get_movement_from_input)(&moveAngle, &moveSpeed); + + if (N(DiveState) != DIVE_STATE_NONE) { + moveSpeedDamping = 80.0f; } else { - var_f20 = 32.0f; + moveSpeedDamping = 32.0f; } - if (sp24 != 0.0f) { - f32 t1; - f32 t2; - f32 t3; + if (moveSpeed != 0.0f) { + f32 changeDirDamping = 8.0f; + f32 sameDirDamping = 32.0f; - t3 = D_802BFDB0_320B20 * D_802BFDB8_320B28; - t1 = 8.0f; - t2 = 32.0f; - - if (t3 > 0.0f) { - D_802BFDB8_320B28 += D_802BFDB0_320B20 / t2; + if (N(InputStickX) * N(InertialStickX) > 0.0f) { + N(InertialStickX) += N(InputStickX) / sameDirDamping; } else { - D_802BFDB8_320B28 += D_802BFDB0_320B20 / t1; + N(InertialStickX) += N(InputStickX) / changeDirDamping; } - if (D_802BFDB0_320B20 > 0.0f) { - if (D_802BFDB0_320B20 < D_802BFDB8_320B28) { - D_802BFDB8_320B28 = D_802BFDB0_320B20; + if (N(InputStickX) > 0.0f) { + if (N(InputStickX) < N(InertialStickX)) { + N(InertialStickX) = N(InputStickX); } } else { - if (D_802BFDB8_320B28 < D_802BFDB0_320B20) { - D_802BFDB8_320B28 = D_802BFDB0_320B20; + if (N(InertialStickX) < N(InputStickX)) { + N(InertialStickX) = N(InputStickX); } } - if (D_802BFDB4_320B24 * D_802BFDBC_320B2C > 0.0f) { - D_802BFDBC_320B2C += D_802BFDB4_320B24 / t2; + if (N(InputStickY) * N(InertialStickY) > 0.0f) { + N(InertialStickY) += N(InputStickY) / sameDirDamping; } else { - D_802BFDBC_320B2C += D_802BFDB4_320B24 / t1; + N(InertialStickY) += N(InputStickY) / changeDirDamping; } - if (D_802BFDB4_320B24 > 0.0f) { - if (D_802BFDB4_320B24 < D_802BFDBC_320B2C) { - D_802BFDBC_320B2C = D_802BFDB4_320B24; + if (N(InputStickY) > 0.0f) { + if (N(InputStickY) < N(InertialStickY)) { + N(InertialStickY) = N(InputStickY); } } else { - if (D_802BFDBC_320B2C < D_802BFDB4_320B24) { - D_802BFDBC_320B2C = D_802BFDB4_320B24; + if (N(InertialStickY) < N(InputStickY)) { + N(InertialStickY) = N(InputStickY); } } - sp20 = clamp_angle(atan2(0.0f, 0.0f, D_802BFDB8_320B28, -D_802BFDBC_320B2C) + gCameras[CAM_DEFAULT].currentYaw); - if (bss_802BFEF8 <= sp24) { - bss_802BFEF8 = bss_802BFEF8 + ((sp24 - bss_802BFEF8) / var_f20); - if (bss_802BFEF8 > sp24) { - bss_802BFEF8 = sp24; + moveAngle = clamp_angle(atan2(0.0f, 0.0f, N(InertialStickX), -N(InertialStickY)) + gCameras[CAM_DEFAULT].currentYaw); + if (N(InertialMoveSpeed) <= moveSpeed) { + N(InertialMoveSpeed) += (moveSpeed - N(InertialMoveSpeed)) / moveSpeedDamping; + if (N(InertialMoveSpeed) > moveSpeed) { + N(InertialMoveSpeed) = moveSpeed; } } else { - bss_802BFEF8 += (sp24 - bss_802BFEF8) / var_f20; + N(InertialMoveSpeed) += (moveSpeed - N(InertialMoveSpeed)) / moveSpeedDamping; } - sp24 = bss_802BFEF8; - bss_802BFEFC = sp20; - sin_cos_rad(DEG_TO_RAD(sp20), &sinTheta, &cosTheta); - bss_802BFF00 += (sp24 * sinTheta) / var_f20; - bss_802BFF04 += (-sp24 * cosTheta) / var_f20; + moveSpeed = N(InertialMoveSpeed); + N(InertialMoveAngle) = moveAngle; + sin_cos_rad(DEG_TO_RAD(moveAngle), &sinAngle, &cosAngle); + N(UnusedMoveX) += ( moveSpeed * sinAngle) / moveSpeedDamping; + N(UnusedMoveZ) += (-moveSpeed * cosAngle) / moveSpeedDamping; } else { - bss_802BFEF8 -= 0.15; - if (bss_802BFEF8 < 0.0f) { - bss_802BFEF8 = 0.0f; - D_802BFDBC_320B2C = 0.0f; - D_802BFDB8_320B28 = 0.0f; + N(InertialMoveSpeed) -= 0.15; + if (N(InertialMoveSpeed) < 0.0f) { + N(InertialMoveSpeed) = 0.0f; + N(InertialStickY) = 0.0f; + N(InertialStickX) = 0.0f; } - sp24 = bss_802BFEF8; - sp20 = bss_802BFEFC; - sin_cos_rad(DEG_TO_RAD(bss_802BFEFC), &sinTheta, &cosTheta); - bss_802BFF00 = sp24 * sinTheta; - bss_802BFF04 = -sp24 * cosTheta; + moveSpeed = N(InertialMoveSpeed); + moveAngle = N(InertialMoveAngle); + sin_cos_rad(DEG_TO_RAD(N(InertialMoveAngle)), &sinAngle, &cosAngle); + N(UnusedMoveX) = moveSpeed * sinAngle; + N(UnusedMoveZ) = -moveSpeed * cosAngle; } - npc->moveSpeed = sp24; - if (sp24 != 0.0f) { - npc->yaw = sp20; - x = npc->pos.x; - z = npc->pos.z; - y = npc->moveToPos.y + -6.0f; - sp3C = (npc->collisionHeight * 0.5f) + (playerStatus->colliderHeight * 0.8f); - if (npc_test_move_taller_with_slipping(npc->collisionChannel, &x, &y, &z, npc->moveSpeed, sp20, sp3C, - npc->collisionRadius) != 0) + + // PART 2: + // apply movement speed and direction to sushie + + sushie->moveSpeed = moveSpeed; + if (moveSpeed != 0.0f) { + sushie->yaw = moveAngle; + x = sushie->pos.x; + z = sushie->pos.z; + y = sushie->moveToPos.y + -6.0f; + depth = (sushie->collisionHeight * 0.5f) + (playerStatus->colliderHeight * 0.8f); + if (npc_test_move_taller_with_slipping(sushie->collisionChannel, &x, &y, &z, + sushie->moveSpeed, moveAngle, depth, sushie->collisionRadius)) { collisionStatus->pushingAgainstWall = NpcHitQueryColliderID; if ((get_collider_flags(NpcHitQueryColliderID) & COLLIDER_FLAGS_SURFACE_TYPE_MASK) == SURFACE_TYPE_DOCK_WALL) { - bss_802BFEF0++; + N(TouchDockTime)++; } else { - bss_802BFEF0 = 0; + N(TouchDockTime) = 0; } - npc->pos.x += (x - npc->pos.x) * 0.5f; - npc->pos.z += (z - npc->pos.z) * 0.5f; + sushie->pos.x += (x - sushie->pos.x) * 0.5f; + sushie->pos.z += (z - sushie->pos.z) * 0.5f; } else { - npc_move_heading(npc, sp24, sp20); + npc_move_heading(sushie, moveSpeed, moveAngle); collisionStatus->pushingAgainstWall = NO_COLLIDER; } - sp24 = 2.0f; - sp20 = clamp_angle(npc->yaw - 30.0f); - x = npc->pos.x; - z = npc->pos.z; - y = npc->moveToPos.y + -6.0f; - sp3C = (npc->collisionHeight * 0.5f) + (playerStatus->colliderHeight * 0.8f); - if (npc_test_move_taller_with_slipping(npc->collisionChannel, &x, &y, &z, sp24, sp20, sp3C, npc->collisionRadius) != 0) { - npc->pos.x += (x - npc->pos.x) / 5.0f; - npc->pos.z += (z - npc->pos.z) / 5.0f; + moveSpeed = 2.0f; + moveAngle = clamp_angle(sushie->yaw - 30.0f); + x = sushie->pos.x; + z = sushie->pos.z; + y = sushie->moveToPos.y + -6.0f; + depth = (sushie->collisionHeight * 0.5f) + (playerStatus->colliderHeight * 0.8f); + if (npc_test_move_taller_with_slipping(sushie->collisionChannel, &x, &y, &z, + moveSpeed, moveAngle, depth, sushie->collisionRadius)) + { + sushie->pos.x += (x - sushie->pos.x) / 5.0f; + sushie->pos.z += (z - sushie->pos.z) / 5.0f; } - sp20 = clamp_angle(npc->yaw + 30.0f); - x = npc->pos.x; - z = npc->pos.z; - y = npc->moveToPos.y + -6.0f; - sp3C = (npc->collisionHeight * 0.5f) + (playerStatus->colliderHeight * 0.8f); - if (npc_test_move_taller_with_slipping(npc->collisionChannel, &x, &y, &z, sp24, sp20, sp3C, npc->collisionRadius) != 0) { - npc->pos.x += (x - npc->pos.x) / 5.0f; - npc->pos.z += (z - npc->pos.z) / 5.0f; + moveAngle = clamp_angle(sushie->yaw + 30.0f); + x = sushie->pos.x; + z = sushie->pos.z; + y = sushie->moveToPos.y + -6.0f; + depth = (sushie->collisionHeight * 0.5f) + (playerStatus->colliderHeight * 0.8f); + if (npc_test_move_taller_with_slipping(sushie->collisionChannel, &x, &y, &z, + moveSpeed, moveAngle, depth, sushie->collisionRadius)) + { + sushie->pos.x += (x - sushie->pos.x) / 5.0f; + sushie->pos.z += (z - sushie->pos.z) / 5.0f; } } - if (bss_802BFEE4 == 0) { - func_802BD368_31E0D8(npc->collisionChannel, npc->pos.x, npc->pos.y, npc->pos.z, npc->yaw, - npc->collisionRadius * 0.5f); - if (bss_802BFEE4 == 0) { - npc->moveSpeed = 3.0f; - npc->moveToPos.y = OriginalPlayerY - (npc->collisionHeight * 0.5f); - bss_802BFEE8 = 0; - if (partnerActionStatus->pressedButtons & BUTTON_C_DOWN) { - bss_802BFEE4 = 1; - npc->moveSpeed = 2.0f; + + // PART 3: + // update diving state + + if (N(DiveState) == DIVE_STATE_NONE) { + N(test_for_water_level)(sushie->collisionChannel, sushie->pos.x, sushie->pos.y, sushie->pos.z, + sushie->yaw, sushie->collisionRadius * 0.5f); + if (N(DiveState) == DIVE_STATE_NONE) { + sushie->moveSpeed = 3.0f; + sushie->moveToPos.y = N(WaterSurfaceY) - (sushie->collisionHeight * 0.5f); + N(DiveTime) = 0; + if (partnerStatus->pressedButtons & BUTTON_C_DOWN) { + N(DiveState) = DIVE_STATE_DELAY; + sushie->moveSpeed = 2.0f; } else { return; } } } - - if (bss_802BFEE4 == 1 && (partnerActionStatus->currentButtons & 4) && bss_802BFEE8 == 0) { - bss_802BFEE4 = 2; + if (N(DiveState) == DIVE_STATE_DELAY) { + if ((partnerStatus->currentButtons & BUTTON_C_DOWN) && N(DiveTime) == 0) { + N(DiveState) = DIVE_STATE_DIVING; + } } - bss_802BFEE8++; - if (bss_802BFEE4 == 2) { - x = npc->pos.x; - y = npc->pos.y; - z = npc->pos.z; - sp3C = npc->collisionHeight; - if (npc_raycast_down_around(npc->collisionChannel, &x, &y, &z, &sp3C, npc->yaw, npc->collisionRadius) != 0) { - var_f20 = ((OriginalPlayerY - (playerStatus->colliderHeight * 2)) - npc->moveToPos.y) * 0.1f; - npc->moveToPos.y += var_f20; - if (npc->moveToPos.y < y + 5.0f) { - npc->moveToPos.y = y + 5.0f; + N(DiveTime)++; + if (N(DiveState) == DIVE_STATE_DIVING) { + x = sushie->pos.x; + y = sushie->pos.y; + z = sushie->pos.z; + depth = sushie->collisionHeight; + if (npc_raycast_down_around(sushie->collisionChannel, &x, &y, &z, &depth, sushie->yaw, sushie->collisionRadius)) { + moveSpeedDamping = ((N(WaterSurfaceY) - (playerStatus->colliderHeight * 2)) - sushie->moveToPos.y) * 0.1f; + sushie->moveToPos.y += moveSpeedDamping; + if (sushie->moveToPos.y < y + 5.0f) { + sushie->moveToPos.y = y + 5.0f; } } else { - var_f20 = ((OriginalPlayerY - (playerStatus->colliderHeight * 2)) - npc->moveToPos.y) * 0.1f; - npc->moveToPos.y += var_f20; + moveSpeedDamping = ((N(WaterSurfaceY) - (playerStatus->colliderHeight * 2)) - sushie->moveToPos.y) * 0.1f; + sushie->moveToPos.y += moveSpeedDamping; } - if (bss_802BFEE8 == ((bss_802BFEE8 / 6) * 6)) { - fx_rising_bubble(0, npc->pos.x, npc->moveToPos.y + (npc->collisionHeight * 0.5f), npc->pos.z, - (OriginalPlayerY - npc->moveToPos.y) - (npc->collisionHeight * 0.5f)); + if (N(DiveTime) % 6 == 0) { + fx_rising_bubble(0, sushie->pos.x, sushie->moveToPos.y + (sushie->collisionHeight * 0.5f), sushie->pos.z, + (N(WaterSurfaceY) - sushie->moveToPos.y) - (sushie->collisionHeight * 0.5f)); } - if (bss_802BFEE8 == 1) { + if (N(DiveTime) == 1) { suggest_player_anim_always_forward(ANIM_MarioW2_DiveSushie); - npc->currentAnim = ANIM_WorldSushie_Ride; + sushie->currentAnim = ANIM_WorldSushie_Ride; } - if (bss_802BFEF4 == 0 && (playerStatus->position.y + (playerStatus->colliderHeight * 0.5f) < OriginalPlayerY)) { - bss_802BFEF4 = 1; + if (!N(IsUnderwater) && (playerStatus->position.y + (playerStatus->colliderHeight * 0.5f) < N(WaterSurfaceY))) { + N(IsUnderwater) = TRUE; playerStatus->renderMode = RENDER_MODE_ALPHATEST; func_802DDFF8(playerStatus->trueAnimation, 4, 2, 0, 0, 0, 0); - func_8003D624(npc, FOLD_TYPE_4, 2, 0, 0, 0, 0); + func_8003D624(sushie, FOLD_TYPE_4, 2, 0, 0, 0, 0); } - if (bss_802BFEE8 >= 10 && (!(partnerActionStatus->currentButtons & BUTTON_C_DOWN) || bss_802BFEE8 >= 30)) { - npc->currentAnim = ANIM_WorldSushie_Rise; - sfx_play_sound_at_npc(SOUND_294 | SOUND_ID_TRIGGER_CHANGE_SOUND, SOUND_SPACE_MODE_0, NPC_PARTNER); - bss_802BFEE4 = 3; + if (N(DiveTime) >= 10) { + if (!(partnerStatus->currentButtons & BUTTON_C_DOWN) || N(DiveTime) >= 30) { + sushie->currentAnim = ANIM_WorldSushie_Rise; + sfx_play_sound_at_npc(SOUND_294 | SOUND_ID_TRIGGER_CHANGE_SOUND, SOUND_SPACE_MODE_0, NPC_PARTNER); + N(DiveState) = DIVE_STATE_SURFACING; + } } } - x = npc->pos.x; - y = npc->moveToPos.y; - z = npc->pos.z; - sp3C = (npc->collisionHeight * 0.5f) + playerStatus->colliderHeight; - if (npc_raycast_up_corners(npc->collisionChannel, &x, &y, &z, &sp3C, npc->yaw, npc->collisionRadius * 0.3f) >= 0) { - npc->moveToPos.y += (((npc->moveToPos.y - y) + sp3C) - ((npc->collisionHeight * 0.5f) + playerStatus->colliderHeight)) * 0.2f; - if (bss_802BFEE8 == ((bss_802BFEE8 / 9) * 9)) { - fx_rising_bubble(0, npc->pos.x, npc->moveToPos.y + (npc->collisionHeight * 0.5f), npc->pos.z, - (OriginalPlayerY - npc->moveToPos.y) - (npc->collisionHeight * 0.5f)); + x = sushie->pos.x; + y = sushie->moveToPos.y; + z = sushie->pos.z; + depth = (sushie->collisionHeight * 0.5f) + playerStatus->colliderHeight; + if (npc_raycast_up_corners(sushie->collisionChannel, &x, &y, &z, &depth, sushie->yaw, sushie->collisionRadius * 0.3f) >= 0) { + sushie->moveToPos.y += (((sushie->moveToPos.y - y) + depth) - ((sushie->collisionHeight * 0.5f) + playerStatus->colliderHeight)) * 0.2f; + if (N(DiveTime) % 9 == 0) { + fx_rising_bubble(0, sushie->pos.x, sushie->moveToPos.y + (sushie->collisionHeight * 0.5f), sushie->pos.z, + (N(WaterSurfaceY) - sushie->moveToPos.y) - (sushie->collisionHeight * 0.5f)); } - } else if (bss_802BFEE4 == 3) { - bss_802BFF08 += 0.14; - if (bss_802BFF08 > 1.8) { - bss_802BFF08 = 1.8f; + } else if (N(DiveState) == DIVE_STATE_SURFACING) { + N(ResurfaceVelY) += 0.14; + if (N(ResurfaceVelY) > 1.8) { + N(ResurfaceVelY) = 1.8f; } - npc->moveToPos.y += bss_802BFF08; - if (bss_802BFEE8 == ((bss_802BFEE8 / 9) * 9)) { - fx_rising_bubble(0, npc->pos.x, npc->moveToPos.y + npc->collisionHeight * 0.5f, npc->pos.z, - (OriginalPlayerY - npc->moveToPos.y) - npc->collisionHeight * 0.5f); + sushie->moveToPos.y += N(ResurfaceVelY); + if (N(DiveTime) % 9 == 0) { + fx_rising_bubble(0, sushie->pos.x, sushie->moveToPos.y + sushie->collisionHeight * 0.5f, sushie->pos.z, + (N(WaterSurfaceY) - sushie->moveToPos.y) - sushie->collisionHeight * 0.5f); } - if ((OriginalPlayerY - npc->moveToPos.y) - (npc->collisionHeight * 0.5f) <= 0.0f) { - if (bss_802BFEF4 != 0) { - bss_802BFEF4 = 0; + if ((N(WaterSurfaceY) - sushie->moveToPos.y) - (sushie->collisionHeight * 0.5f) <= 0.0f) { + if (N(IsUnderwater)) { + N(IsUnderwater) = FALSE; func_802DDFF8(ANIM_Mario1_Idle, 0, 0, 0, 0, 0, 0); - func_8003D624(npc, FOLD_TYPE_NONE, 0, 0, 0, 0, 0); + func_8003D624(sushie, FOLD_TYPE_NONE, 0, 0, 0, 0, 0); } - bss_802BFEE4 = 0; - npc->currentAnim = ANIM_WorldSushie_Ride; - npc->moveToPos.y = OriginalPlayerY - (npc->collisionHeight * 0.5f); + N(DiveState) = DIVE_STATE_NONE; + sushie->currentAnim = ANIM_WorldSushie_Ride; + sushie->moveToPos.y = N(WaterSurfaceY) - (sushie->collisionHeight * 0.5f); suggest_player_anim_always_forward(ANIM_MarioW2_RideSushie); } } } -s32 func_802BE280_31EFF0(s32 arg0, f32* x, f32* y, f32* z, f32 length, f32 radius, f32* yaw) { - f32 sinAngle, cosAngle, hitX, hitY, hitZ, totalLength, hitNx, hitNy, hitNz; +s32 N(test_ray_to_wall_center)(s32 unused, f32* x, f32* y, f32* z, f32 length, f32 radius, f32* yaw) { + f32 sinAngle, cosAngle, totalLength; + f32 hitX, hitY, hitZ; + f32 hitNx, hitNy, hitNz; s32 hitResult; sin_cos_rad(DEG_TO_RAD(*yaw), &sinAngle, &cosAngle); cosAngle = -cosAngle; totalLength = radius + length; - hitResult = test_ray_colliders(COLLISION_CHANNEL_10000, *x, *y, *z, sinAngle, 0.0f, cosAngle, &hitX, &hitY, &hitZ, &totalLength, &hitNx, &hitNy, &hitNz); + hitResult = test_ray_colliders(COLLISION_CHANNEL_10000, *x, *y, *z, sinAngle, 0.0f, cosAngle, + &hitX, &hitY, &hitZ, &totalLength, &hitNx, &hitNy, &hitNz); if (hitResult >= 0) { *yaw = atan2(0.0f, 0.0f, hitNx, hitNz); @@ -323,406 +346,439 @@ s32 func_802BE280_31EFF0(s32 arg0, f32* x, f32* y, f32* z, f32 length, f32 radiu return hitResult; } -API_CALLABLE(func_802BE3A4_31F114) { +API_CALLABLE(N(UseAbility)) { PlayerStatus* playerStatus = &gPlayerStatus; PlayerData* playerData = &gPlayerData; CollisionStatus* collisionStatus = &gCollisionStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; - Npc* npc = script->owner2.npc; - s32 colliderFlags; - f32 yTemp; - f64 zTemp; - f64 xTemp; - f32 x, y, z; - f32 angle; - f32 dist; - f32 sp34; - f32 sinTheta; - f32 cosTheta; + PartnerStatus* partnerStatus = &gPartnerStatus; + Npc* sushie = script->owner2.npc; + s32 surfaceType; + f32 x, y, z, dist; + f32 angle, speed; + f32 sinAngle, cosAngle; s32 collider; - s32 t; + + #define USE_STATE functionTemp[0] + enum { + SWIM_STATE_INIT = 0, + SWIM_STATE_BEGIN = 20, + SWIM_STATE_ENTER_WATER = 21, + SWIM_STATE_EMBARK_1 = 22, + SWIM_STATE_EMBARK_2 = 23, + SWIM_STATE_EMBARK_3 = 24, + SWIM_STATE_EMBARK_4 = 25, + SWIM_STATE_RIDING = 1, + SWIM_STATE_DISEMBARK_1 = 3, + SWIM_STATE_DISEMBARK_2 = 4, + SWIM_STATE_DISEMBARK_3 = 5, + SWIM_STATE_EXIT_WATER = 10, + }; if (isInitialCall) { - func_802BF920_320690(npc); - bss_802BFEFC = 0.0f; - bss_802BFEF8 = 0.0f; - bss_802BFF00 = 0.0f; - bss_802BFF04 = 0.0f; - bss_802BFF08 = 0.0f; - script->functionTemp[0] = 0; + N(try_cancel_tweester)(sushie); + N(InertialMoveAngle) = 0.0f; + N(InertialMoveSpeed) = 0.0f; + N(UnusedMoveX) = 0.0f; + N(UnusedMoveZ) = 0.0f; + N(ResurfaceVelY) = 0.0f; + script->USE_STATE = SWIM_STATE_INIT; } playerData->partnerUsedTime[PARTNER_SUSHIE]++; playerStatus->animFlags &= ~PA_FLAG_RIDING_PARTNER; - switch (script->functionTemp[0]) { - case 0: + switch (script->USE_STATE) { + case SWIM_STATE_INIT: if (!gGameStatusPtr->keepUsingPartnerOnMapChange) { + // are we colliding with a solid (non-entity) wall? collider = collisionStatus->currentWall; - if (collider >= 0 && (collider & COLLISION_WITH_ENTITY_BIT) == 0) { - collider = get_collider_flags(collider) & COLLIDER_FLAGS_SURFACE_TYPE_MASK; - if (collider != SURFACE_TYPE_DOCK_WALL) { - return ApiStatus_DONE1; - } - script->functionTemp[0] = 20; - break; + if (collider <= NO_COLLIDER || collider & COLLISION_WITH_ENTITY_BIT) { + return ApiStatus_DONE1; } + // is it a dock wall + collider = get_collider_flags(collider) & COLLIDER_FLAGS_SURFACE_TYPE_MASK; + if (collider != SURFACE_TYPE_DOCK_WALL) { + return ApiStatus_DONE1; + } + script->USE_STATE = SWIM_STATE_BEGIN; + } else { + // resume riding state from previous map + sushie->moveToPos.y = sushie->pos.y; + playerStatus->position.y = sushie->moveToPos.y + 16.0f; + N(IsRiding) = TRUE; + sushie->flags |= NPC_FLAG_8; + sushie->flags &= ~NPC_FLAG_GRAVITY; + sushie->flags |= NPC_FLAG_IGNORE_PLAYER_COLLISION; + suggest_player_anim_always_forward(ANIM_MarioW2_RideSushie); + disable_player_shadow(); + disable_npc_shadow(sushie); + func_8003D624(sushie, FOLD_TYPE_4, 2, 0, 0, 0, 0); + sushie->currentAnim = ANIM_WorldSushie_Ride; + sushie->moveSpeed = playerStatus->runSpeed; + sushie->jumpScale = 0.0f; + partnerStatus->partnerActionState = PARTNER_ACTION_USE; + gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; + partnerStatus->actingPartner = PARTNER_SUSHIE; + N(DiveState) = DIVE_STATE_NONE; + N(DiveTime) = 0; + script->functionTemp[2] = 0; + script->USE_STATE = SWIM_STATE_RIDING; + } + break; + + case SWIM_STATE_BEGIN: + if (collisionStatus->currentWall <= NO_COLLIDER) { return ApiStatus_DONE1; } - npc->moveToPos.y = npc->pos.y; - playerStatus->position.y = npc->moveToPos.y + 16.0f; - bss_802BFEEC = 1; - npc->flags |= NPC_FLAG_8; - npc->flags &= ~NPC_FLAG_GRAVITY; - npc->flags |= NPC_FLAG_IGNORE_PLAYER_COLLISION; - suggest_player_anim_always_forward(ANIM_MarioW2_RideSushie); - disable_player_shadow(); - disable_npc_shadow(npc); - func_8003D624(npc, FOLD_TYPE_4, 2, 0, 0, 0, 0); - npc->currentAnim = ANIM_WorldSushie_Ride; - npc->moveSpeed = playerStatus->runSpeed; - npc->jumpScale = 0.0f; - partnerActionStatus->partnerActionState = PARTNER_ACTION_USE; - gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; - partnerActionStatus->actingPartner = PARTNER_SUSHIE; - bss_802BFEE4 = 0; - bss_802BFEE8 = 0; - script->functionTemp[2] = 0; - script->functionTemp[0] = 1; - break; - case 20: - if (collisionStatus->currentWall >= 0) { - get_collider_center(collisionStatus->currentWall, &x, &y, &z); - angle = atan2(x, z, playerStatus->position.x, playerStatus->position.z); - x = playerStatus->position.x; - y = playerStatus->position.y; - z = playerStatus->position.z; - collider = func_802BE280_31EFF0(0, &x, &y, &z, playerStatus->colliderDiameter * 0.5f, - 2.0f * playerStatus->colliderDiameter, &angle); - colliderFlags = -1; - if (collider >= 0) { - colliderFlags = get_collider_flags(collider) & COLLIDER_FLAGS_SURFACE_TYPE_MASK; - } - if (colliderFlags == SURFACE_TYPE_DOCK_WALL) { - bss_802BFEEC = 1; - set_action_state(ACTION_STATE_RIDE); - disable_player_static_collisions(); - disable_player_input(); - npc->collisionChannel = COLLISION_CHANNEL_80000; - npc->moveToPos.x = playerStatus->position.x; - npc->moveToPos.y = playerStatus->position.y; - npc->moveToPos.z = playerStatus->position.z; - npc->yaw = angle; - playerStatus->targetYaw = angle; - npc->renderYaw = 90.0f; - add_vec2D_polar(&npc->moveToPos.x, &npc->moveToPos.z, 40.0f, npc->yaw); - x = npc->moveToPos.x; - y = npc->moveToPos.y; - z = npc->moveToPos.z; - dist = 100.0f; - collider = npc_raycast_down_around(npc->collisionChannel, &x, &y, &z, &dist, - npc->yaw, npc->collisionRadius); - npc->currentAnim = ANIM_WorldSushie_Run; - npc->duration = 12; - npc->moveToPos.y = y - (npc->collisionHeight * 0.5f); - suggest_player_anim_allow_backward(ANIM_Mario1_Idle); - script->functionTemp[0]++; - break; - } + // check for obstructions between player and center of current wall + get_collider_center(collisionStatus->currentWall, &x, &y, &z); + angle = atan2(x, z, playerStatus->position.x, playerStatus->position.z); + x = playerStatus->position.x; + y = playerStatus->position.y; + z = playerStatus->position.z; + collider = N(test_ray_to_wall_center)(0, &x, &y, &z, + playerStatus->colliderDiameter * 0.5f, 2.0f * playerStatus->colliderDiameter, &angle); + // check surface type for wall + surfaceType = SURFACE_TYPE_INVALID; + if (collider > NO_COLLIDER) { + surfaceType = get_collider_flags(collider) & COLLIDER_FLAGS_SURFACE_TYPE_MASK; } - return ApiStatus_DONE1; - case 21: - npc->pos.x += ((npc->moveToPos.x - npc->pos.x) / npc->duration); - npc->pos.y += ((npc->moveToPos.y - npc->pos.y) / npc->duration); - npc->pos.z += ((npc->moveToPos.z - npc->pos.z) / npc->duration); - npc->duration--; - if (npc->duration != 0) { - if (npc->duration == 2) { + if (surfaceType != SURFACE_TYPE_DOCK_WALL) { + return ApiStatus_DONE1; + } + + N(IsRiding) = TRUE; + set_action_state(ACTION_STATE_RIDE); + disable_player_static_collisions(); + disable_player_input(); + sushie->collisionChannel = COLLISION_CHANNEL_80000; + sushie->moveToPos.x = playerStatus->position.x; + sushie->moveToPos.y = playerStatus->position.y; + sushie->moveToPos.z = playerStatus->position.z; + sushie->yaw = angle; + playerStatus->targetYaw = angle; + sushie->renderYaw = 90.0f; + add_vec2D_polar(&sushie->moveToPos.x, &sushie->moveToPos.z, 40.0f, sushie->yaw); + x = sushie->moveToPos.x; + y = sushie->moveToPos.y; + z = sushie->moveToPos.z; + dist = 100.0f; + collider = npc_raycast_down_around(sushie->collisionChannel, &x, &y, &z, &dist, + sushie->yaw, sushie->collisionRadius); + sushie->currentAnim = ANIM_WorldSushie_Run; + sushie->duration = 12; + sushie->moveToPos.y = y - (sushie->collisionHeight * 0.5f); + suggest_player_anim_allow_backward(ANIM_Mario1_Idle); + script->USE_STATE++; // SWIM_STATE_ENTER_WATER + break; + + case SWIM_STATE_ENTER_WATER: + sushie->pos.x += (sushie->moveToPos.x - sushie->pos.x) / sushie->duration; + sushie->pos.y += (sushie->moveToPos.y - sushie->pos.y) / sushie->duration; + sushie->pos.z += (sushie->moveToPos.z - sushie->pos.z) / sushie->duration; + sushie->duration--; + if (sushie->duration != 0) { + if (sushie->duration == 2) { sfx_play_sound_at_npc(SOUND_JUMP_2081, SOUND_SPACE_MODE_0, NPC_PARTNER); suggest_player_anim_allow_backward(ANIM_Mario1_BeforeJump); } break; } - npc->collisionChannel = COLLISION_CHANNEL_10000; - npc->flags |= NPC_FLAG_8; - npc->flags &= ~(NPC_FLAG_GRAVITY | NPC_FLAG_IGNORE_WORLD_COLLISION); - disable_npc_shadow(npc); - func_8003D624(npc, FOLD_TYPE_4, 2, 0, 0, 0, 0); - npc->currentAnim = ANIM_WorldSushie_Ride; + sushie->collisionChannel = COLLISION_CHANNEL_10000; + sushie->flags |= NPC_FLAG_8; + sushie->flags &= ~(NPC_FLAG_GRAVITY | NPC_FLAG_IGNORE_WORLD_COLLISION); + disable_npc_shadow(sushie); + func_8003D624(sushie, FOLD_TYPE_4, 2, 0, 0, 0, 0); + sushie->currentAnim = ANIM_WorldSushie_Ride; playerStatus->flags |= PS_FLAG_MOVEMENT_LOCKED; - dist = dist2D(playerStatus->position.x, playerStatus->position.z, npc->moveToPos.x, npc->moveToPos.z); - npc->jumpVelocity = 5.0f; - npc->jumpScale = 0.6f; - y = npc->moveToPos.y - playerStatus->position.y; - npc->duration = (2.0f * npc->jumpVelocity) / 0.6f; - npc->moveSpeed = dist / npc->duration; - npc->jumpVelocity += y / npc->duration; + dist = dist2D(playerStatus->position.x, playerStatus->position.z, sushie->moveToPos.x, sushie->moveToPos.z); + sushie->jumpVelocity = 5.0f; + sushie->jumpScale = 0.6f; + y = sushie->moveToPos.y - playerStatus->position.y; + sushie->duration = (2.0f * sushie->jumpVelocity) / 0.6f; + sushie->moveSpeed = dist / sushie->duration; + sushie->jumpVelocity += y / sushie->duration; suggest_player_anim_allow_backward(ANIM_Mario1_Jump); - script->functionTemp[0]++; - fx_rising_bubble(0, npc->pos.x, npc->moveToPos.y + (npc->collisionHeight * 0.5f), npc->pos.z, 0.0f); - return 0; - case 23: - fx_rising_bubble(0, npc->pos.x, npc->moveToPos.y + (npc->collisionHeight * 0.5f), npc->pos.z, 0.0f); + script->USE_STATE++; // SWIM_STATE_EMBARK_1 + fx_rising_bubble(0, sushie->pos.x, sushie->moveToPos.y + (sushie->collisionHeight * 0.5f), sushie->pos.z, 0.0f); + break; + + case SWIM_STATE_EMBARK_2: + fx_rising_bubble(0, sushie->pos.x, sushie->moveToPos.y + (sushie->collisionHeight * 0.5f), sushie->pos.z, 0.0f); // fallthrough - case 22: - case 24: - script->functionTemp[0]++; + case SWIM_STATE_EMBARK_1: + case SWIM_STATE_EMBARK_3: + script->USE_STATE++; // fallthrough - case 25: - playerStatus->position.y += npc->jumpVelocity; - npc->jumpVelocity -= npc->jumpScale; - add_vec2D_polar(&playerStatus->position.x, &playerStatus->position.z, npc->moveSpeed, npc->yaw); - if (npc->jumpVelocity <= 0.0f) { + case SWIM_STATE_EMBARK_4: + playerStatus->position.y += sushie->jumpVelocity; + sushie->jumpVelocity -= sushie->jumpScale; + add_vec2D_polar(&playerStatus->position.x, &playerStatus->position.z, sushie->moveSpeed, sushie->yaw); + if (sushie->jumpVelocity <= 0.0f) { suggest_player_anim_allow_backward(ANIM_Mario1_Fall); } gCameras[CAM_DEFAULT].targetPos.x = playerStatus->position.x; gCameras[CAM_DEFAULT].targetPos.y = playerStatus->position.y; gCameras[CAM_DEFAULT].targetPos.z = playerStatus->position.z; - if (npc->duration == 0) { - set_action_state(ACTION_STATE_RIDE); - disable_player_shadow(); - playerStatus->flags &= ~PS_FLAG_MOVEMENT_LOCKED; - suggest_player_anim_always_forward(ANIM_MarioW2_RideSushie); - sfx_play_sound_at_npc(SOUND_2013, SOUND_SPACE_MODE_0, NPC_PARTNER); - playerStatus->position.x = npc->pos.x; - playerStatus->position.y = npc->pos.y; - playerStatus->position.z = npc->pos.z; - playerStatus->targetYaw = npc->yaw; - npc->moveSpeed = 3.0f; - partnerActionStatus->partnerActionState = PARTNER_ACTION_USE; - gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; - partnerActionStatus->actingPartner = PARTNER_SUSHIE; - bss_802BFEE4 = 0; - bss_802BFEE8 = 0; - script->functionTemp[2] = 0; - script->functionTemp[0] = 1; - } else { - npc->duration--; + if (sushie->duration != 0) { + sushie->duration--; + break; } + set_action_state(ACTION_STATE_RIDE); + disable_player_shadow(); + playerStatus->flags &= ~PS_FLAG_MOVEMENT_LOCKED; + suggest_player_anim_always_forward(ANIM_MarioW2_RideSushie); + sfx_play_sound_at_npc(SOUND_2013, SOUND_SPACE_MODE_0, NPC_PARTNER); + playerStatus->position.x = sushie->pos.x; + playerStatus->position.y = sushie->pos.y; + playerStatus->position.z = sushie->pos.z; + playerStatus->targetYaw = sushie->yaw; + sushie->moveSpeed = 3.0f; + partnerStatus->partnerActionState = PARTNER_ACTION_USE; + gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; + partnerStatus->actingPartner = PARTNER_SUSHIE; + N(DiveState) = DIVE_STATE_NONE; + N(DiveTime) = 0; + script->functionTemp[2] = 0; + script->USE_STATE = SWIM_STATE_RIDING; break; - case 1: + + case SWIM_STATE_RIDING: playerStatus->animFlags |= PA_FLAG_RIDING_PARTNER; - func_802BD414_31E184(npc); - if (bss_802BFEE4 == 0) { + N(update_riding_physics)(sushie); + if (N(DiveState) == DIVE_STATE_NONE) { script->functionTemp[2]++; if (script->functionTemp[2] > 20) { script->functionTemp[2] -= 40; } - npc->pos.y = npc->moveToPos.y + (abs(script->functionTemp[2]) * 0.125f); + sushie->pos.y = sushie->moveToPos.y + abs(script->functionTemp[2]) / 8.0f; if (script->functionTemp[2] == 5) { - func_802BD20C_31DF7C(&angle, &sp34); - if (bss_802BFEE4 == 0) { - if (sp34 != 0.0f) { + N(get_movement_from_input)(&angle, &speed); + if (N(DiveState) == DIVE_STATE_NONE) { + if (speed != 0.0f) { sfx_play_sound_at_npc(SOUND_2015, SOUND_SPACE_MODE_0, NPC_PARTNER); } else { sfx_play_sound_at_npc(SOUND_2014, SOUND_SPACE_MODE_0, NPC_PARTNER); } } } - if (bss_802BFEF8 == 0.0f && !((gGameStatusPtr->frameCounter % 10) & 0xFFFF)) { - fx_rising_bubble(0, npc->pos.x, npc->moveToPos.y + (npc->collisionHeight * 0.5f), npc->pos.z, 0.0f); + if (N(InertialMoveSpeed) == 0.0f && !((gGameStatusPtr->frameCounter % 10) & 0xFFFF)) { + fx_rising_bubble(0, + sushie->pos.x, + sushie->moveToPos.y + (sushie->collisionHeight * 0.5f), + sushie->pos.z, + 0); } } else { - npc->pos.y = npc->moveToPos.y; + sushie->pos.y = sushie->moveToPos.y; } if (!(playerStatus->animFlags & PA_FLAG_RIDING_PARTNER)) { - func_802BD100_31DE70(); + N(sync_player_position)(); } - if (bss_802BFEE4 == 1) { + if (N(DiveState) == DIVE_STATE_DELAY) { if (!(gGameStatusPtr->frameCounter % 19)) { - yTemp = npc->moveToPos.y + (npc->collisionHeight * 0.5f); - fx_rising_bubble(0,npc->pos.x, yTemp, npc->pos.z, OriginalPlayerY - npc->pos.y); + fx_rising_bubble(0, + sushie->pos.x, + sushie->moveToPos.y + (sushie->collisionHeight * 0.5f), + sushie->pos.z, + N(WaterSurfaceY) - sushie->pos.y); } - } else if (bss_802BFEF8 != 0.0f && bss_802BFEE4 < 2) { + } else if (N(InertialMoveSpeed) != 0.0f && N(DiveState) < DIVE_STATE_DIVING) { if (!(gGameStatusPtr->frameCounter % 7)) { - yTemp = npc->moveToPos.y + (npc->collisionHeight * 0.5f); - - fx_rising_bubble(0, npc->pos.x, yTemp, npc->pos.z, bss_802BFEE4 != 0 ? OriginalPlayerY - npc->pos.y : 0.0f); + fx_rising_bubble(0, + sushie->pos.x, + sushie->moveToPos.y + (sushie->collisionHeight * 0.5f), + sushie->pos.z, + N(DiveState) != DIVE_STATE_NONE ? N(WaterSurfaceY) - sushie->pos.y : 0); } } - gCameras[CAM_DEFAULT].targetPos.x = npc->pos.x; - gCameras[CAM_DEFAULT].targetPos.y = OriginalPlayerY; - gCameras[CAM_DEFAULT].targetPos.z = npc->pos.z; - if ((partnerActionStatus->pressedButtons & (BUTTON_B | BUTTON_C_DOWN)) || bss_802BFEF0 >= 30) { - if (bss_802BFEF4 == 0) { - x = npc->pos.x; - y = npc->moveToPos.y + npc->collisionHeight; - z = npc->pos.z; + gCameras[CAM_DEFAULT].targetPos.x = sushie->pos.x; + gCameras[CAM_DEFAULT].targetPos.y = N(WaterSurfaceY); + gCameras[CAM_DEFAULT].targetPos.z = sushie->pos.z; + if ((partnerStatus->pressedButtons & (BUTTON_B | BUTTON_C_DOWN)) || N(TouchDockTime) >= 30) { + if (N(IsUnderwater)) { + break; + } + x = sushie->pos.x; + y = sushie->moveToPos.y + sushie->collisionHeight; + z = sushie->pos.z; - t = npc_test_move_taller_with_slipping(npc->collisionChannel, &x, &y, &z, 10.0f, npc->yaw, - npc->collisionHeight, npc->collisionRadius); - if (t != 0) { - collisionStatus->pushingAgainstWall = npc->currentWall = NpcHitQueryColliderID; - } else { - collisionStatus->pushingAgainstWall = NO_COLLIDER; - } + if (npc_test_move_taller_with_slipping(sushie->collisionChannel, &x, &y, &z, 10.0f, + sushie->yaw, sushie->collisionHeight, sushie->collisionRadius) + ) { + collisionStatus->pushingAgainstWall = sushie->currentWall = NpcHitQueryColliderID; + } else { + collisionStatus->pushingAgainstWall = NO_COLLIDER; + } - if (npc->currentWall < 0 || npc->currentWall & COLLISION_WITH_ENTITY_BIT) { - if (bss_802BFEE4 == 2 && bss_802BFEE8 == 1) { - sfx_play_sound_at_npc(SOUND_294, SOUND_SPACE_MODE_0, NPC_PARTNER); - } - break; + if (sushie->currentWall < 0 || sushie->currentWall & COLLISION_WITH_ENTITY_BIT) { + if (N(DiveState) == DIVE_STATE_DIVING && N(DiveTime) == 1) { + sfx_play_sound_at_npc(SOUND_294, SOUND_SPACE_MODE_0, NPC_PARTNER); } - collider = get_collider_flags(npc->currentWall) & COLLIDER_FLAGS_SURFACE_TYPE_MASK; - if (collider != SURFACE_TYPE_DOCK_WALL) { - if (bss_802BFEE4 == 2 && bss_802BFEE8 == 1) { - sfx_play_sound_at_npc(SOUND_294, SOUND_SPACE_MODE_0, NPC_PARTNER); - } - break; + break; + } + collider = get_collider_flags(sushie->currentWall) & COLLIDER_FLAGS_SURFACE_TYPE_MASK; + if (collider != SURFACE_TYPE_DOCK_WALL) { + if (N(DiveState) == DIVE_STATE_DIVING && N(DiveTime) == 1) { + sfx_play_sound_at_npc(SOUND_294, SOUND_SPACE_MODE_0, NPC_PARTNER); } - bss_802BFEF0 = 0; - x = npc->pos.x; - z = npc->pos.z; - y = npc->moveToPos.y + 100.0f; - add_vec2D_polar(&x, &z, 40.0f, npc->yaw); + break; + } + N(TouchDockTime) = 0; + x = sushie->pos.x; + z = sushie->pos.z; + y = sushie->moveToPos.y + 100.0f; + add_vec2D_polar(&x, &z, 40.0f, sushie->yaw); + dist = 100.0f; + // this var is a condition here + collider = npc_raycast_down_around(sushie->collisionChannel, &x, &y, &z, &dist, sushie->yaw, 0.0f); + if (collider) { + get_collider_center(sushie->currentWall, &x, &y, &z); + dist = dist2D(sushie->pos.x, sushie->pos.z, x, z); + sin_cos_rad(DEG_TO_RAD(atan2(sushie->pos.x, sushie->pos.z, x, z)), &sinAngle, &cosAngle); + x = sushie->pos.x + ((sinAngle * dist) * 0.6); + z = sushie->pos.z - ((cosAngle * dist) * 0.6); dist = 100.0f; - collider = npc_raycast_down_around(npc->collisionChannel, &x, &y, &z, &dist, npc->yaw, 0.0f); - if (collider != 0) { - get_collider_center(npc->currentWall, &x, &y, &z); - dist = dist2D(npc->pos.x, npc->pos.z, x, z); - sin_cos_rad(DEG_TO_RAD(atan2(npc->pos.x, npc->pos.z, x, z)), &sinTheta, &cosTheta); - xTemp = npc->pos.x + ((sinTheta * dist) * 0.6); - zTemp = npc->pos.z - ((cosTheta * dist) * 0.6); - dist = 100.0f; - x = xTemp; - z = zTemp; - npc_raycast_down_around(npc->collisionChannel, &x, &y, &z, &dist, npc->yaw, 0.0f); - npc->moveToPos.y = y; - npc->moveToPos.x = x; - npc->moveToPos.z = z; - playerStatus->targetYaw = atan2(playerStatus->position.x, playerStatus->position.z, x, z); - npc->yaw = playerStatus->targetYaw; - dist = dist2D(playerStatus->position.x, playerStatus->position.z, npc->moveToPos.x, npc->moveToPos.z); - npc->jumpVelocity = 5.0f; - npc->jumpScale = 0.6f; - npc->duration = (2.0f * npc->jumpVelocity) / 0.6f; - npc->moveSpeed = dist / npc->duration; - npc->jumpVelocity += (npc->moveToPos.y - playerStatus->position.y) / npc->duration; - sfx_play_sound_at_npc(SOUND_JUMP_2081, SOUND_SPACE_MODE_0, NPC_PARTNER); - suggest_player_anim_allow_backward(ANIM_Mario1_BeforeJump); - enable_player_shadow(); - playerStatus->flags |= PS_FLAG_MOVEMENT_LOCKED; - script->functionTemp[0] = 3; - } + npc_raycast_down_around(sushie->collisionChannel, &x, &y, &z, &dist, sushie->yaw, 0.0f); + sushie->moveToPos.y = y; + sushie->moveToPos.x = x; + sushie->moveToPos.z = z; + playerStatus->targetYaw = atan2(playerStatus->position.x, playerStatus->position.z, x, z); + sushie->yaw = playerStatus->targetYaw; + dist = dist2D(playerStatus->position.x, playerStatus->position.z, sushie->moveToPos.x, sushie->moveToPos.z); + sushie->jumpVelocity = 5.0f; + sushie->jumpScale = 0.6f; + sushie->duration = (2.0f * sushie->jumpVelocity) / 0.6f; + sushie->moveSpeed = dist / sushie->duration; + sushie->jumpVelocity += (sushie->moveToPos.y - playerStatus->position.y) / sushie->duration; + sfx_play_sound_at_npc(SOUND_JUMP_2081, SOUND_SPACE_MODE_0, NPC_PARTNER); + suggest_player_anim_allow_backward(ANIM_Mario1_BeforeJump); + enable_player_shadow(); + playerStatus->flags |= PS_FLAG_MOVEMENT_LOCKED; + script->USE_STATE = SWIM_STATE_DISEMBARK_1; } } break; - case 3: + case SWIM_STATE_DISEMBARK_1: suggest_player_anim_allow_backward(ANIM_Mario1_Jump); - script->functionTemp[0]++; + script->USE_STATE++; // fallthrough - case 4: - if (npc->jumpVelocity <= 0.0f) { + case SWIM_STATE_DISEMBARK_2: + if (sushie->jumpVelocity <= 0.0f) { suggest_player_anim_allow_backward(ANIM_Mario1_Fall); - script->functionTemp[0]++; + script->USE_STATE++; } // fallthrough - case 5: - if (npc->jumpVelocity <= 0.0f) { - playerStatus->position.y = y = player_check_collision_below(npc->jumpVelocity, &collider); + case SWIM_STATE_DISEMBARK_3: + if (sushie->jumpVelocity <= 0.0f) { + playerStatus->position.y = y = player_check_collision_below(sushie->jumpVelocity, &collider); if (collider > 0) { suggest_player_anim_allow_backward(ANIM_Mario1_Land); } } else { - playerStatus->position.y += npc->jumpVelocity; + playerStatus->position.y += sushie->jumpVelocity; } - npc->jumpVelocity -= npc->jumpScale; + sushie->jumpVelocity -= sushie->jumpScale; gCameras[CAM_DEFAULT].targetPos.x = playerStatus->position.x; gCameras[CAM_DEFAULT].targetPos.y = playerStatus->position.y; gCameras[CAM_DEFAULT].targetPos.z = playerStatus->position.z; - if (npc->duration != 0) { - add_vec2D_polar(&playerStatus->position.x, &playerStatus->position.z, npc->moveSpeed, npc->yaw); - npc->duration--; + if (sushie->duration != 0) { + add_vec2D_polar(&playerStatus->position.x, &playerStatus->position.z, sushie->moveSpeed, sushie->yaw); + sushie->duration--; break; } if (collider >= 0) { playerStatus->flags &= ~PS_FLAG_MOVEMENT_LOCKED; suggest_player_anim_allow_backward(ANIM_Mario1_Idle); - npc->flags |= NPC_FLAG_IGNORE_WORLD_COLLISION; - dist = dist2D(npc->pos.x, npc->pos.z, npc->moveToPos.x, npc->moveToPos.z) + + sushie->flags |= NPC_FLAG_IGNORE_WORLD_COLLISION; + dist = dist2D(sushie->pos.x, sushie->pos.z, sushie->moveToPos.x, sushie->moveToPos.z) + (playerStatus->colliderDiameter * 0.5f); - npc->jumpVelocity = 8.0f; - npc->jumpScale = 1.0f; - npc->moveSpeed = 4.0f; - y = npc->moveToPos.y - npc->pos.y; - npc->duration = (2.0f * npc->jumpVelocity) / npc->jumpScale; - npc->moveSpeed = dist / npc->duration; - npc->jumpVelocity += y / npc->duration; - script->functionTemp[0] = 10; + sushie->jumpVelocity = 8.0f; + sushie->jumpScale = 1.0f; + sushie->moveSpeed = 4.0f; + y = sushie->moveToPos.y - sushie->pos.y; + sushie->duration = (2.0f * sushie->jumpVelocity) / sushie->jumpScale; + sushie->moveSpeed = dist / sushie->duration; + sushie->jumpVelocity += y / sushie->duration; + script->USE_STATE = SWIM_STATE_EXIT_WATER; } break; - case 10: - npc->pos.y += npc->jumpVelocity; - npc->jumpVelocity = npc->jumpVelocity - npc->jumpScale; - add_vec2D_polar(&npc->pos.x, &npc->pos.z, npc->moveSpeed, npc->yaw); - if (npc->duration == 0) { + case SWIM_STATE_EXIT_WATER: + sushie->pos.y += sushie->jumpVelocity; + sushie->jumpVelocity -= sushie->jumpScale; + add_vec2D_polar(&sushie->pos.x, &sushie->pos.z, sushie->moveSpeed, sushie->yaw); + if (sushie->duration == 0) { enable_player_static_collisions(); enable_player_input(); set_action_state(ACTION_STATE_IDLE); - enable_npc_shadow(npc); - partner_clear_player_tracking(npc); - bss_802BFEEC = 0; - npc->flags &= ~NPC_FLAG_8; - npc->flags |= NPC_FLAG_GRAVITY; - npc->flags &= ~NPC_FLAG_IGNORE_WORLD_COLLISION; + enable_npc_shadow(sushie); + partner_clear_player_tracking(sushie); + N(IsRiding) = FALSE; + sushie->flags &= ~NPC_FLAG_8; + sushie->flags |= NPC_FLAG_GRAVITY; + sushie->flags &= ~NPC_FLAG_IGNORE_WORLD_COLLISION; gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; - partnerActionStatus->partnerActionState = PARTNER_ACTION_NONE; - partnerActionStatus->actingPartner = 0; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; + partnerStatus->actingPartner = 0; func_802DDFF8(ANIM_Mario1_Idle, 0, 0, 0, 0, 0, 0); - func_8003D624(npc, FOLD_TYPE_NONE, 0, 0, 0, 0, 0); + func_8003D624(sushie, FOLD_TYPE_NONE, 0, 0, 0, 0, 0); return ApiStatus_DONE1; } - npc->duration--; + sushie->duration--; break; } return ApiStatus_BLOCK; } EvtScript EVS_WorldSushie_UseAbility = { - EVT_CALL(func_802BE3A4_31F114) + EVT_CALL(N(UseAbility)) EVT_RETURN EVT_END }; -void world_sushie_init(Npc* sushie) { +void N(init)(Npc* sushie) { sushie->collisionHeight = 24; sushie->collisionRadius = 36; sushie->collisionChannel = COLLISION_CHANNEL_10000; - bss_802BFEEC = 0; - bss_802BFEE4 = 0; - bss_802BFEE8 = 0; - bss_802BFEF0 = 0; - bss_802BFEF4 = 0; + N(IsRiding) = FALSE; + N(DiveState) = DIVE_STATE_NONE; + N(DiveTime) = 0; + N(TouchDockTime) = 0; + N(IsUnderwater) = FALSE; } -API_CALLABLE(SushieTakeOut) { +API_CALLABLE(N(TakeOut)) { Npc* sushie = script->owner2.npc; if (isInitialCall) { partner_init_get_out(sushie); } - return partner_get_out(sushie) ? ApiStatus_DONE1 : ApiStatus_BLOCK; + if (partner_get_out(sushie)) { + return ApiStatus_DONE1; + } else { + return ApiStatus_BLOCK; + } } EvtScript EVS_WorldSushie_TakeOut = { - EVT_CALL(SushieTakeOut) + EVT_CALL(N(TakeOut)) EVT_RETURN EVT_END }; -TweesterPhysics* SushieTweesterPhysicsPtr = &SushieTweesterPhysics; +TweesterPhysics* N(TweesterPhysicsPtr) = &N(TweesterPhysicsData); -API_CALLABLE(SushieUpdate) { +API_CALLABLE(N(Update)) { Npc* sushie = script->owner2.npc; f32 sinAngle, cosAngle, liftoffVelocity; Entity* entity; if (isInitialCall) { partner_walking_enable(sushie, 1); - mem_clear(SushieTweesterPhysicsPtr, sizeof(TweesterPhysics)); + mem_clear(N(TweesterPhysicsPtr), sizeof(TweesterPhysics)); TweesterTouchingPartner = NULL; } @@ -734,60 +790,60 @@ API_CALLABLE(SushieUpdate) { return ApiStatus_BLOCK; } - switch (SushieTweesterPhysicsPtr->state) { + switch (N(TweesterPhysicsPtr)->state) { case TWEESTER_PARTNER_INIT: - SushieTweesterPhysicsPtr->state++; - SushieTweesterPhysicsPtr->prevFlags = sushie->flags; - SushieTweesterPhysicsPtr->radius = fabsf(dist2D(sushie->pos.x, sushie->pos.z, + N(TweesterPhysicsPtr)->state++; + N(TweesterPhysicsPtr)->prevFlags = sushie->flags; + N(TweesterPhysicsPtr)->radius = fabsf(dist2D(sushie->pos.x, sushie->pos.z, entity->position.x, entity->position.z)); - SushieTweesterPhysicsPtr->angle = atan2(entity->position.x, entity->position.z, sushie->pos.x, sushie->pos.z); - SushieTweesterPhysicsPtr->angularVelocity = 6.0f; - SushieTweesterPhysicsPtr->liftoffVelocityPhase = 50.0f; - SushieTweesterPhysicsPtr->countdown = 120; + N(TweesterPhysicsPtr)->angle = atan2(entity->position.x, entity->position.z, sushie->pos.x, sushie->pos.z); + N(TweesterPhysicsPtr)->angularVelocity = 6.0f; + N(TweesterPhysicsPtr)->liftoffVelocityPhase = 50.0f; + N(TweesterPhysicsPtr)->countdown = 120; sushie->flags |= NPC_FLAG_IGNORE_CAMERA_FOR_YAW | NPC_FLAG_IGNORE_PLAYER_COLLISION | NPC_FLAG_IGNORE_WORLD_COLLISION | NPC_FLAG_8; sushie->flags &= ~NPC_FLAG_GRAVITY; case TWEESTER_PARTNER_ATTRACT: - sin_cos_rad(DEG_TO_RAD(SushieTweesterPhysicsPtr->angle), &sinAngle, &cosAngle); - sushie->pos.x = entity->position.x + (sinAngle * SushieTweesterPhysicsPtr->radius); - sushie->pos.z = entity->position.z - (cosAngle * SushieTweesterPhysicsPtr->radius); - SushieTweesterPhysicsPtr->angle = clamp_angle(SushieTweesterPhysicsPtr->angle - SushieTweesterPhysicsPtr->angularVelocity); + sin_cos_rad(DEG_TO_RAD(N(TweesterPhysicsPtr)->angle), &sinAngle, &cosAngle); + sushie->pos.x = entity->position.x + (sinAngle * N(TweesterPhysicsPtr)->radius); + sushie->pos.z = entity->position.z - (cosAngle * N(TweesterPhysicsPtr)->radius); + N(TweesterPhysicsPtr)->angle = clamp_angle(N(TweesterPhysicsPtr)->angle - N(TweesterPhysicsPtr)->angularVelocity); - if (SushieTweesterPhysicsPtr->radius > 20.0f) { - SushieTweesterPhysicsPtr->radius--; - } else if (SushieTweesterPhysicsPtr->radius < 19.0f) { - SushieTweesterPhysicsPtr->radius++; + if (N(TweesterPhysicsPtr)->radius > 20.0f) { + N(TweesterPhysicsPtr)->radius--; + } else if (N(TweesterPhysicsPtr)->radius < 19.0f) { + N(TweesterPhysicsPtr)->radius++; } - liftoffVelocity = sin_rad(DEG_TO_RAD(SushieTweesterPhysicsPtr->liftoffVelocityPhase)) * 3.0f; - SushieTweesterPhysicsPtr->liftoffVelocityPhase += 3.0f; + liftoffVelocity = sin_rad(DEG_TO_RAD(N(TweesterPhysicsPtr)->liftoffVelocityPhase)) * 3.0f; + N(TweesterPhysicsPtr)->liftoffVelocityPhase += 3.0f; - if (SushieTweesterPhysicsPtr->liftoffVelocityPhase > 150.0f) { - SushieTweesterPhysicsPtr->liftoffVelocityPhase = 150.0f; + if (N(TweesterPhysicsPtr)->liftoffVelocityPhase > 150.0f) { + N(TweesterPhysicsPtr)->liftoffVelocityPhase = 150.0f; } sushie->pos.y += liftoffVelocity; - sushie->renderYaw = clamp_angle(360.0f - SushieTweesterPhysicsPtr->angle); - SushieTweesterPhysicsPtr->angularVelocity += 0.8; + sushie->renderYaw = clamp_angle(360.0f - N(TweesterPhysicsPtr)->angle); + N(TweesterPhysicsPtr)->angularVelocity += 0.8; - if (SushieTweesterPhysicsPtr->angularVelocity > 40.0f) { - SushieTweesterPhysicsPtr->angularVelocity = 40.0f; + if (N(TweesterPhysicsPtr)->angularVelocity > 40.0f) { + N(TweesterPhysicsPtr)->angularVelocity = 40.0f; } - if (--SushieTweesterPhysicsPtr->countdown == 0) { - SushieTweesterPhysicsPtr->state++; + if (--N(TweesterPhysicsPtr)->countdown == 0) { + N(TweesterPhysicsPtr)->state++; } break; case TWEESTER_PARTNER_HOLD: - sushie->flags = SushieTweesterPhysicsPtr->prevFlags; - SushieTweesterPhysicsPtr->countdown = 30; - SushieTweesterPhysicsPtr->state++; + sushie->flags = N(TweesterPhysicsPtr)->prevFlags; + N(TweesterPhysicsPtr)->countdown = 30; + N(TweesterPhysicsPtr)->state++; break; case TWEESTER_PARTNER_RELEASE: partner_walking_update_player_tracking(sushie); partner_walking_update_motion(sushie); - if (--SushieTweesterPhysicsPtr->countdown == 0) { - SushieTweesterPhysicsPtr->state = TWEESTER_PARTNER_INIT; + if (--N(TweesterPhysicsPtr)->countdown == 0) { + N(TweesterPhysicsPtr)->state = TWEESTER_PARTNER_INIT; TweesterTouchingPartner = NULL; } break; @@ -797,21 +853,21 @@ API_CALLABLE(SushieUpdate) { } EvtScript EVS_WorldSushie_Update = { - EVT_CALL(SushieUpdate) + EVT_CALL(N(Update)) EVT_RETURN EVT_END }; -void func_802BF920_320690(Npc* sushie) { +void N(try_cancel_tweester)(Npc* sushie) { if (TweesterTouchingPartner != NULL) { TweesterTouchingPartner = NULL; - sushie->flags = SushieTweesterPhysicsPtr->prevFlags; - SushieTweesterPhysicsPtr->state = TWEESTER_PARTNER_INIT; + sushie->flags = N(TweesterPhysicsPtr)->prevFlags; + N(TweesterPhysicsPtr)->state = TWEESTER_PARTNER_INIT; partner_clear_player_tracking(sushie); } } -API_CALLABLE(SushiePutAway) { +API_CALLABLE(N(PutAway)) { Npc* sushie = script->owner2.npc; if (isInitialCall) { @@ -823,42 +879,42 @@ API_CALLABLE(SushiePutAway) { } EvtScript EVS_WorldSushie_PutAway = { - EVT_CALL(SushiePutAway) + EVT_CALL(N(PutAway)) EVT_RETURN EVT_END }; -void world_sushie_pre_battle(Npc* sushie) { - PartnerActionStatus* sushieActionStatus = &gPartnerActionStatus; +void N(pre_battle)(Npc* sushie) { + PartnerStatus* partnerStatus = &gPartnerStatus; - if (bss_802BFEEC) { - sushieActionStatus->npc = *sushie; - sushieActionStatus->partnerAction_unk_1 = TRUE; + if (N(IsRiding)) { + partnerStatus->npc = *sushie; + partnerStatus->shouldResumeAbility = TRUE; enable_player_static_collisions(); enable_player_input(); set_action_state(ACTION_STATE_IDLE); partner_clear_player_tracking(sushie); } - sushieActionStatus->actingPartner = PARTNER_SUSHIE; + partnerStatus->actingPartner = PARTNER_SUSHIE; } -void world_sushie_post_battle(Npc* sushie) { - PartnerActionStatus* sushieActionStatus = &gPartnerActionStatus; +void N(post_battle)(Npc* sushie) { + PartnerStatus* partnerStatus = &gPartnerStatus; - if (sushieActionStatus->partnerAction_unk_1) { - *sushie = sushieActionStatus->npc; + if (partnerStatus->shouldResumeAbility) { + *sushie = partnerStatus->npc; partner_use_ability(); } } -API_CALLABLE(func_802BFAB8_320828) { +API_CALLABLE(N(EnterMap)) { Npc* partnerNPC = get_npc_unsafe(NPC_PARTNER); PlayerStatus* playerStatus = &gPlayerStatus; if (isInitialCall) { script->functionTemp[0] = 0; - OriginalPlayerY = playerStatus->position.y; + N(WaterSurfaceY) = playerStatus->position.y; } switch (script->functionTemp[0]) { @@ -869,9 +925,9 @@ API_CALLABLE(func_802BFAB8_320828) { partnerNPC->pos.x = playerStatus->position.x; partnerNPC->pos.z = playerStatus->position.z; partnerNPC->pos.y = playerStatus->position.y; - func_802BD368_31E0D8(partnerNPC->collisionChannel, partnerNPC->pos.x, partnerNPC->pos.y, partnerNPC->pos.z, + N(test_for_water_level)(partnerNPC->collisionChannel, partnerNPC->pos.x, partnerNPC->pos.y, partnerNPC->pos.z, partnerNPC->yaw, partnerNPC->collisionRadius * 0.5f); - partnerNPC->pos.y = OriginalPlayerY - (partnerNPC->collisionHeight * 0.5f); + partnerNPC->pos.y = N(WaterSurfaceY) - (partnerNPC->collisionHeight * 0.5f); partnerNPC->yaw = atan2(partnerNPC->pos.x, partnerNPC->pos.z, script->varTable[1], script->varTable[3]); partnerNPC->currentAnim = ANIM_WorldSushie_Ride; partnerNPC->jumpScale = 0.0f; @@ -890,16 +946,15 @@ API_CALLABLE(func_802BFAB8_320828) { suggest_player_anim_always_forward(ANIM_MarioW2_RideSushie); if ((partnerNPC->yaw >= 0.0f) && (partnerNPC->yaw <= 180.0f)) { partnerNPC->yawCamOffset = partnerNPC->yaw; - partnerNPC->isFacingAway = 1; + partnerNPC->isFacingAway = TRUE; } } - script->functionTemp[1] = 25; script->functionTemp[0] = 1; break; case 1: npc_move_heading(partnerNPC, partnerNPC->moveSpeed, partnerNPC->yaw); - func_802BD100_31DE70(); + N(sync_player_position)(); if (!(script->functionTemp[1] & 3)) { fx_rising_bubble(0, partnerNPC->pos.x, partnerNPC->moveToPos.y + @@ -911,22 +966,19 @@ API_CALLABLE(func_802BFAB8_320828) { if (script->varTable[12] == 1) { set_action_state(ACTION_STATE_RIDE); partner_use_ability(); - return ApiStatus_DONE2; + } else { + enable_player_static_collisions(); + enable_player_input(); } - - enable_player_static_collisions(); - enable_player_input(); return ApiStatus_DONE2; } - break; } - return ApiStatus_BLOCK; } -EvtScript EVS_WorldSushie_Riding = { - EVT_CALL(func_802BFAB8_320828) +EvtScript EVS_WorldSushie_EnterMap = { + EVT_CALL(N(EnterMap)) EVT_RETURN EVT_END }; diff --git a/src/world/partner/sushie.h b/src/world/partner/sushie.h index 4def965064..b8e8a1c093 100644 --- a/src/world/partner/sushie.h +++ b/src/world/partner/sushie.h @@ -8,10 +8,12 @@ void world_sushie_init(Npc*); void world_sushie_pre_battle(Npc*); void world_sushie_post_battle(Npc*); +void world_sushie_sync_player_position(void); + extern EvtScript EVS_WorldSushie_TakeOut; extern EvtScript EVS_WorldSushie_Update; extern EvtScript EVS_WorldSushie_UseAbility; extern EvtScript EVS_WorldSushie_PutAway; -extern EvtScript EVS_WorldSushie_Riding; +extern EvtScript EVS_WorldSushie_EnterMap; #endif diff --git a/src/world/partner/watt.c b/src/world/partner/watt.c index 76173eaa0e..6d1eea2cf9 100644 --- a/src/world/partner/watt.c +++ b/src/world/partner/watt.c @@ -8,62 +8,71 @@ #define NAMESPACE world_watt void force_player_anim(AnimID); -void func_802BE014_31DB84(void); +void N(sync_held_position)(void); +void N(update_player_carry_anim)(void); -s32 D_802BE250_31DDC0[] = {24, 6}; +BSS b32 N(D_802BE300); +BSS s32 N(AbilityState); +BSS b32 N(D_802BE308); +BSS b32 N(IsPlayerHolding); +BSS EffectInstance* N(StaticEffect); +BSS s32 N(D_802BE314); // unused (padding?) -BSS s32 D_802BE300; -BSS s32 D_802BE304; -BSS s32 D_802BE308; -BSS s32 D_802BE30C; -BSS EffectInstance* WattStaticEffect; -BSS s32 D_802BE314; -BSS TweesterPhysics WattTweesterPhysics; +enum { + // next two states lock input for a few frames, during which the ability can be canceled + SHINING_STATE_INIT = 40, + SHINING_STATE_DELAY = 41, + SHINING_STATE_BEGIN = 20, + SHINING_STATE_GATHER = 21, + SHINING_STATE_HOLDING = 1, + SHINING_STATE_RELEASE = 2, +}; -void func_802BD100_31CC70(Npc* npc) { +void N(create_static_effect)(Npc* npc) { if (!(npc->flags & NPC_FLAG_INVISIBLE)) { - if (WattStaticEffect == NULL) { - WattStaticEffect = fx_static_status(0, npc->pos.x, npc->pos.y + 13.0f, npc->pos.z, 0.9f, 5, 0); + if (N(StaticEffect) == NULL) { + N(StaticEffect) = fx_static_status(0, npc->pos.x, npc->pos.y + 13.0f, npc->pos.z, 0.9f, 5, 0); } } } -s32 world_watt_dispose_static_effect(void) { - if (WattStaticEffect != NULL) { - WattStaticEffect->data.staticStatus->unk_28 = 1; - WattStaticEffect = NULL; - return 1; +void N(dispose_static_effect)(void) { + if (N(StaticEffect) != NULL) { + N(StaticEffect)->data.staticStatus->timeLeft = 1; + N(StaticEffect) = NULL; } } -void func_802BD1AC_31CD1C(s32 arg0) { - EffectInstance* effect = WattStaticEffect; - StaticStatusFXData* data = effect->data.staticStatus; - f32 tmp; - s32 parts; +s32 N(EffectAnimLengths)[] = { 24, 6 }; // second type is different from length in static_status.c (6 vs 12) + +void N(reset_static_effect)(s32 type) { + EffectInstance* effect = N(StaticEffect); + StaticStatusFXData* part = effect->data.staticStatus; + f32 invisTime; + s32 count; s32 i; - data->unk_00 = arg0; - tmp = D_802BE250_31DDC0[arg0] * 0.5f; - parts = effect->numParts - 1; + part->type = type; + invisTime = N(EffectAnimLengths)[type] * 0.5f; + count = effect->numParts - 1; - data++; - for (i = 1; i < parts; i++, data++) { - data->unk_20 = -1.0f - (tmp * (i & 1)); + part++; + for (i = 1; i < count; i++, part++) { + part->frame = -1.0f - (invisTime * (i & 1)); } } -void world_watt_init(Npc* npc) { +void N(init)(Npc* npc) { npc->collisionHeight = 24; npc->collisionRadius = 24; - D_802BE308 = 0; - D_802BE300 = 0; - D_802BE30C = 0; - D_802BE304 = 20; - WattStaticEffect = NULL; + N(D_802BE308) = FALSE; + N(D_802BE300) = FALSE; + N(IsPlayerHolding) = FALSE; + N(AbilityState) = SHINING_STATE_BEGIN; + N(StaticEffect) = NULL; } -API_CALLABLE(func_802BD27C_31CDEC) { +API_CALLABLE(N(TakeOut)) { Npc* watt = script->owner2.npc; if (isInitialCall) { @@ -78,25 +87,26 @@ API_CALLABLE(func_802BD27C_31CDEC) { } EvtScript EVS_WorldWatt_TakeOut = { - EVT_CALL(func_802BD27C_31CDEC) + EVT_CALL(N(TakeOut)) EVT_RETURN EVT_END }; -TweesterPhysics* WattTweesterPhysicsPtr = &WattTweesterPhysics; +BSS TweesterPhysics N(TweesterPhysicsData); +TweesterPhysics* N(TweesterPhysicsPtr) = &N(TweesterPhysicsData); -s32 D_802BE278_31DDE8 = 0; +b32 N(WattIsMoving) = FALSE; -API_CALLABLE(WattUpdate) { +API_CALLABLE(N(Update)) { PlayerData* playerData = &gPlayerData; Npc* watt = script->owner2.npc; f32 sinAngle, cosAngle, liftoffVelocity; Entity* entity; - if (!gPartnerActionStatus.partnerAction_unk_1) { + if (!gPartnerStatus.shouldResumeAbility) { if (isInitialCall) { partner_flying_enable(watt, 1); - mem_clear(WattTweesterPhysicsPtr, sizeof(TweesterPhysics)); + mem_clear(N(TweesterPhysicsPtr), sizeof(TweesterPhysics)); TweesterTouchingPartner = NULL; } @@ -104,188 +114,185 @@ API_CALLABLE(WattUpdate) { playerData->partnerUsedTime[PARTNER_WATT]++; if (entity == NULL) { - func_802BD100_31CC70(watt); + N(create_static_effect)(watt); partner_flying_update_player_tracking(watt); partner_flying_update_motion(watt); if (watt->moveSpeed != 0.0f) { - if (D_802BE278_31DDE8 == 0) { - D_802BE278_31DDE8 = 1; - func_802BD1AC_31CD1C(1); + if (!N(WattIsMoving)) { + N(WattIsMoving) = TRUE; + N(reset_static_effect)(1); watt->currentAnim = ANIM_WorldWatt_Run; } - } else if (D_802BE278_31DDE8 != 0) { - D_802BE278_31DDE8 = 0; - func_802BD1AC_31CD1C(0); - watt->currentAnim = ANIM_WorldWatt_Idle; + } else { + if (N(WattIsMoving)) { + N(WattIsMoving) = FALSE; + N(reset_static_effect)(0); + watt->currentAnim = ANIM_WorldWatt_Idle; + } } - - if (WattStaticEffect != NULL) { - WattStaticEffect->data.staticStatus->unk_04 = watt->pos.x; - WattStaticEffect->data.staticStatus->unk_08 = watt->pos.y + 13.0f; - WattStaticEffect->data.staticStatus->unk_0C = watt->pos.z; + if (N(StaticEffect) != NULL) { + N(StaticEffect)->data.staticStatus->pos.x = watt->pos.x; + N(StaticEffect)->data.staticStatus->pos.y = watt->pos.y + 13.0f; + N(StaticEffect)->data.staticStatus->pos.z = watt->pos.z; } - return ApiStatus_BLOCK; } - switch (WattTweesterPhysicsPtr->state) { + switch (N(TweesterPhysicsPtr)->state) { case TWEESTER_PARTNER_INIT: - WattTweesterPhysicsPtr->state++; - WattTweesterPhysicsPtr->prevFlags = watt->flags; - WattTweesterPhysicsPtr->radius = fabsf(dist2D(watt->pos.x, watt->pos.z, - entity->position.x, entity->position.z)); - WattTweesterPhysicsPtr->angle = atan2(entity->position.x, entity->position.z, watt->pos.x, watt->pos.z); - WattTweesterPhysicsPtr->angularVelocity = 6.0f; - WattTweesterPhysicsPtr->liftoffVelocityPhase = 50.0f; - WattTweesterPhysicsPtr->countdown = 120; + N(TweesterPhysicsPtr)->state++; + N(TweesterPhysicsPtr)->prevFlags = watt->flags; + N(TweesterPhysicsPtr)->radius = fabsf(dist2D(watt->pos.x, watt->pos.z, entity->position.x, entity->position.z)); + N(TweesterPhysicsPtr)->angle = atan2(entity->position.x, entity->position.z, watt->pos.x, watt->pos.z); + N(TweesterPhysicsPtr)->angularVelocity = 6.0f; + N(TweesterPhysicsPtr)->liftoffVelocityPhase = 50.0f; + N(TweesterPhysicsPtr)->countdown = 120; watt->flags |= NPC_FLAG_IGNORE_CAMERA_FOR_YAW | NPC_FLAG_IGNORE_PLAYER_COLLISION | NPC_FLAG_IGNORE_WORLD_COLLISION | NPC_FLAG_8; watt->flags &= ~NPC_FLAG_GRAVITY; case TWEESTER_PARTNER_ATTRACT: - sin_cos_rad(DEG_TO_RAD(WattTweesterPhysicsPtr->angle), &sinAngle, &cosAngle); - watt->pos.x = (entity->position.x + (sinAngle * WattTweesterPhysicsPtr->radius)); - watt->pos.z = (entity->position.z - (cosAngle * WattTweesterPhysicsPtr->radius)); - WattTweesterPhysicsPtr->angle = clamp_angle(WattTweesterPhysicsPtr->angle - WattTweesterPhysicsPtr->angularVelocity); + sin_cos_rad(DEG_TO_RAD(N(TweesterPhysicsPtr)->angle), &sinAngle, &cosAngle); + watt->pos.x = entity->position.x + (sinAngle * N(TweesterPhysicsPtr)->radius); + watt->pos.z = entity->position.z - (cosAngle * N(TweesterPhysicsPtr)->radius); + N(TweesterPhysicsPtr)->angle = clamp_angle(N(TweesterPhysicsPtr)->angle - N(TweesterPhysicsPtr)->angularVelocity); - if (WattTweesterPhysicsPtr->radius > 20.0f) { - WattTweesterPhysicsPtr->radius--; - } else if (WattTweesterPhysicsPtr->radius < 19.0f) { - WattTweesterPhysicsPtr->radius++; + if (N(TweesterPhysicsPtr)->radius > 20.0f) { + N(TweesterPhysicsPtr)->radius--; + } else if (N(TweesterPhysicsPtr)->radius < 19.0f) { + N(TweesterPhysicsPtr)->radius++; } - liftoffVelocity = sin_rad(DEG_TO_RAD(WattTweesterPhysicsPtr->liftoffVelocityPhase)) * 3.0f; - WattTweesterPhysicsPtr->liftoffVelocityPhase += 3.0f; + liftoffVelocity = sin_rad(DEG_TO_RAD(N(TweesterPhysicsPtr)->liftoffVelocityPhase)) * 3.0f; + N(TweesterPhysicsPtr)->liftoffVelocityPhase += 3.0f; - if (WattTweesterPhysicsPtr->liftoffVelocityPhase > 150.0f) { - WattTweesterPhysicsPtr->liftoffVelocityPhase = 150.0f; + if (N(TweesterPhysicsPtr)->liftoffVelocityPhase > 150.0f) { + N(TweesterPhysicsPtr)->liftoffVelocityPhase = 150.0f; } watt->pos.y += liftoffVelocity; - watt->renderYaw = clamp_angle(360.0f - WattTweesterPhysicsPtr->angle); - WattTweesterPhysicsPtr->angularVelocity += 0.8; + watt->renderYaw = clamp_angle(360.0f - N(TweesterPhysicsPtr)->angle); + N(TweesterPhysicsPtr)->angularVelocity += 0.8; - if (WattTweesterPhysicsPtr->angularVelocity > 40.0f) { - WattTweesterPhysicsPtr->angularVelocity = 40.0f; + if (N(TweesterPhysicsPtr)->angularVelocity > 40.0f) { + N(TweesterPhysicsPtr)->angularVelocity = 40.0f; } - if (--WattTweesterPhysicsPtr->countdown == 0) { - WattTweesterPhysicsPtr->state++; + if (--N(TweesterPhysicsPtr)->countdown == 0) { + N(TweesterPhysicsPtr)->state++; } break; case TWEESTER_PARTNER_HOLD: - watt->flags = WattTweesterPhysicsPtr->prevFlags; - WattTweesterPhysicsPtr->countdown = 30; - WattTweesterPhysicsPtr->state++; + watt->flags = N(TweesterPhysicsPtr)->prevFlags; + N(TweesterPhysicsPtr)->countdown = 30; + N(TweesterPhysicsPtr)->state++; break; case TWEESTER_PARTNER_RELEASE: partner_flying_update_player_tracking(watt); partner_flying_update_motion(watt); - if (--WattTweesterPhysicsPtr->countdown == 0) { - WattTweesterPhysicsPtr->state = TWEESTER_PARTNER_INIT; + if (--N(TweesterPhysicsPtr)->countdown == 0) { + N(TweesterPhysicsPtr)->state = TWEESTER_PARTNER_INIT; TweesterTouchingPartner = NULL; } break; } - if (WattStaticEffect != 0) { - WattStaticEffect->data.staticStatus->unk_04 = watt->pos.x; - WattStaticEffect->data.staticStatus->unk_08 = watt->pos.y + 13.0f; - WattStaticEffect->data.staticStatus->unk_0C = watt->pos.z; + if (N(StaticEffect) != NULL) { + N(StaticEffect)->data.staticStatus->pos.x = watt->pos.x; + N(StaticEffect)->data.staticStatus->pos.y = watt->pos.y + 13.0f; + N(StaticEffect)->data.staticStatus->pos.z = watt->pos.z; } } return ApiStatus_BLOCK; } EvtScript EVS_WorldWatt_Update = { - EVT_CALL(WattUpdate) + EVT_CALL(N(Update)) EVT_RETURN EVT_END }; -void func_802BD710_31D280(Npc* watt) { +void N(try_cancel_tweester)(Npc* watt) { if (TweesterTouchingPartner != NULL) { TweesterTouchingPartner = NULL; - watt->flags = WattTweesterPhysicsPtr->prevFlags; - WattTweesterPhysicsPtr->state = TWEESTER_PARTNER_INIT; + watt->flags = N(TweesterPhysicsPtr)->prevFlags; + N(TweesterPhysicsPtr)->state = TWEESTER_PARTNER_INIT; partner_clear_player_tracking(watt); } } -API_CALLABLE(func_802BD754_31D2C4) { +API_CALLABLE(N(UseAbility)) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; Npc* npc = script->owner2.npc; + s32 actionState; if (isInitialCall) { - func_802BD710_31D280(npc); - if (!(playerStatus->animFlags & PA_FLAG_CHANGING_MAP)) { - if (!partnerActionStatus->partnerAction_unk_1) { - if ((partnerActionStatus->partnerActionState != ACTION_STATE_IDLE) || - (func_800EA52C(PARTNER_WATT) && !is_starting_conversation())) - { - if (gGameStatusPtr->keepUsingPartnerOnMapChange) { - if (playerStatus->animFlags & (PA_FLAG_USING_WATT | PA_FLAG_WATT_IN_HANDS)) { - D_802BE304 = 20; - } else { - D_802BE304 = 40; - } - } else if (playerStatus->animFlags & PA_FLAG_USING_WATT) { - D_802BE304 = 2; - } else { - D_802BE304 = 40; - } + N(try_cancel_tweester)(npc); + if ((playerStatus->animFlags & PA_FLAG_CHANGING_MAP)) { + return ApiStatus_DONE2; + } + if (!partnerStatus->shouldResumeAbility) { + if (partnerStatus->partnerActionState == ACTION_STATE_IDLE + && (!func_800EA52C(PARTNER_WATT) || is_starting_conversation())) + { + return ApiStatus_DONE2; + } + + if (gGameStatusPtr->keepUsingPartnerOnMapChange) { + if (playerStatus->animFlags & (PA_FLAG_USING_WATT | PA_FLAG_WATT_IN_HANDS)) { + N(AbilityState) = SHINING_STATE_BEGIN; } else { - return ApiStatus_DONE2; + N(AbilityState) = SHINING_STATE_INIT; } + } else if (playerStatus->animFlags & PA_FLAG_USING_WATT) { + N(AbilityState) = SHINING_STATE_RELEASE; } else { - partnerActionStatus->partnerAction_unk_1 = FALSE; - playerStatus->animFlags |= (PA_FLAG_USING_WATT | PA_FLAG_WATT_IN_HANDS); - func_802BE014_31DB84(); - npc->currentAnim = ANIM_WorldWatt_Idle; - D_802BE304 = 1; - script->functionTemp[1] = 2; + N(AbilityState) = SHINING_STATE_INIT; } } else { - return ApiStatus_DONE2; + partnerStatus->shouldResumeAbility = FALSE; + playerStatus->animFlags |= (PA_FLAG_USING_WATT | PA_FLAG_WATT_IN_HANDS); + N(update_player_carry_anim)(); + npc->currentAnim = ANIM_WorldWatt_Idle; + N(AbilityState) = SHINING_STATE_HOLDING; + script->functionTemp[1] = 2; } } - switch (D_802BE304) { - case 40: + switch (N(AbilityState)) { + case SHINING_STATE_INIT: if (playerStatus->inputDisabledCount != 0) { return ApiStatus_DONE2; } script->functionTemp[1] = 3; - D_802BE304 = 41; + N(AbilityState) = SHINING_STATE_DELAY; script->functionTemp[2] = playerStatus->inputDisabledCount; break; - case 41: + case SHINING_STATE_DELAY: if (script->functionTemp[1] == 0) { - if (script->functionTemp[2] >= playerStatus->inputDisabledCount) { - if (!(playerStatus->animFlags & PA_FLAG_CHANGING_MAP)) { - if (func_800EA52C(PARTNER_WATT)) { - if (!is_starting_conversation()) { - D_802BE304 = 20; - break; - } - } - } + if (script->functionTemp[2] < playerStatus->inputDisabledCount + || playerStatus->animFlags & PA_FLAG_CHANGING_MAP + || !func_800EA52C(PARTNER_WATT) + || is_starting_conversation() + ) { + return ApiStatus_DONE2; } - return ApiStatus_DONE2; + N(AbilityState) = SHINING_STATE_BEGIN; + break; } script->functionTemp[1]--; break; } - switch (D_802BE304) { - case 20: + switch (N(AbilityState)) { + case SHINING_STATE_BEGIN: if (gGameStatusPtr->keepUsingPartnerOnMapChange) { playerStatus->animFlags |= PA_FLAG_USING_WATT; - D_802BE30C = 1; + N(IsPlayerHolding) = TRUE; npc->flags |= NPC_FLAG_IGNORE_PLAYER_COLLISION | NPC_FLAG_8; npc->flags &= ~(NPC_FLAG_JUMPING | NPC_FLAG_GRAVITY); - gGameStatusPtr->keepUsingPartnerOnMapChange = 0; - partnerActionStatus->partnerActionState = PARTNER_ACTION_USE; - partnerActionStatus->actingPartner = PARTNER_WATT; + gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; + partnerStatus->partnerActionState = PARTNER_ACTION_USE; + partnerStatus->actingPartner = PARTNER_WATT; npc->moveToPos.x = playerStatus->position.x; npc->moveToPos.y = playerStatus->position.y + 5.0f; npc->moveToPos.z = playerStatus->position.z; @@ -294,17 +301,17 @@ API_CALLABLE(func_802BD754_31D2C4) { npc->yaw = playerStatus->targetYaw; npc->currentAnim = ANIM_WorldWatt_Idle; playerStatus->animFlags |= PA_FLAG_WATT_IN_HANDS; - func_802BE014_31DB84(); + N(update_player_carry_anim)(); npc_set_palswap_mode_A(npc, 1); script->functionTemp[1] = 2; - D_802BE304 = 1; + N(AbilityState) = SHINING_STATE_HOLDING; } else { playerStatus->animFlags |= PA_FLAG_USING_WATT; - D_802BE30C = 1; + N(IsPlayerHolding) = TRUE; npc->flags &= ~(NPC_FLAG_JUMPING | NPC_FLAG_GRAVITY); - gGameStatusPtr->keepUsingPartnerOnMapChange = 0; - partnerActionStatus->partnerActionState = PARTNER_ACTION_USE; - partnerActionStatus->actingPartner = PARTNER_WATT; + gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; + partnerStatus->partnerActionState = PARTNER_ACTION_USE; + partnerStatus->actingPartner = PARTNER_WATT; partner_force_player_flip_done(); npc->moveToPos.x = playerStatus->position.x; npc->moveToPos.y = playerStatus->position.y + 5.0f; @@ -313,10 +320,10 @@ API_CALLABLE(func_802BD754_31D2C4) { add_vec2D_polar(&npc->moveToPos.x, &npc->moveToPos.z, 15.0f, playerStatus->targetYaw); npc->duration = 8; npc->yaw = atan2(npc->pos.x, npc->pos.z, playerStatus->position.x, playerStatus->position.z); - D_802BE304++; + N(AbilityState)++; // SHINING_STATE_GATHER } break; - case 21: + case SHINING_STATE_GATHER: npc->pos.x += (npc->moveToPos.x - npc->pos.x) / npc->duration; npc->pos.y += (npc->moveToPos.y - npc->pos.y) / npc->duration; npc->pos.z += (npc->moveToPos.z - npc->pos.z) / npc->duration; @@ -324,47 +331,50 @@ API_CALLABLE(func_802BD754_31D2C4) { if (npc->duration == 0) { npc->yaw = playerStatus->targetYaw; npc->currentAnim = ANIM_WorldWatt_Idle; - partnerActionStatus->actingPartner = PARTNER_WATT; + partnerStatus->actingPartner = PARTNER_WATT; playerStatus->animFlags |= PA_FLAG_WATT_IN_HANDS; - func_802BE014_31DB84(); + N(update_player_carry_anim)(); script->functionTemp[1] = 2; - D_802BE304 = 1; + N(AbilityState) = SHINING_STATE_HOLDING; } break; - case 1: - world_watt_sync_held_position(); + case SHINING_STATE_HOLDING: + N(sync_held_position)(); + // immediately cancel state on touching fire if ((playerStatus->flags & PS_FLAG_HIT_FIRE)) { - D_802BE304 = 2; - } else { - s32 actionState = playerStatus->actionState; - - if (actionState != ACTION_STATE_USE_SPINNING_FLOWER) { - if (script->functionTemp[1] != 0) { - script->functionTemp[1]--; - } else if ( - actionState == ACTION_STATE_IDLE || - actionState == ACTION_STATE_WALK || - actionState == ACTION_STATE_RUN || - actionState == ACTION_STATE_LAND) - { - if (partnerActionStatus->pressedButtons & BUTTON_B) { - D_802BE304 = 2; - } - } - } + N(AbilityState) = SHINING_STATE_RELEASE; + break; + } + if (playerStatus->actionState == ACTION_STATE_USE_SPINNING_FLOWER) { + break; + } + // wait for begin holding cooldown + if (script->functionTemp[1] != 0) { + script->functionTemp[1]--; + break; + } + // allow stop-holding input + actionState = playerStatus->actionState; + if ((actionState == ACTION_STATE_IDLE + || actionState == ACTION_STATE_WALK + || actionState == ACTION_STATE_RUN + || actionState == ACTION_STATE_LAND) + && partnerStatus->pressedButtons & BUTTON_B + ) { + N(AbilityState) = SHINING_STATE_RELEASE; } break; } - if (D_802BE304 == 2) { + if (N(AbilityState) == SHINING_STATE_RELEASE) { playerStatus->animFlags &= ~(PA_FLAG_WATT_IN_HANDS | PA_FLAG_USING_WATT); npc->currentAnim = ANIM_WorldWatt_Idle; partner_clear_player_tracking(npc); - D_802BE30C = 0; - partnerActionStatus->actingPartner = PARTNER_NONE; - partnerActionStatus->partnerActionState = PARTNER_ACTION_NONE; + N(IsPlayerHolding) = FALSE; + partnerStatus->actingPartner = PARTNER_NONE; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; - D_802BE304 = 20; + N(AbilityState) = SHINING_STATE_BEGIN; npc_set_palswap_mode_A(npc, 0); if (!(playerStatus->flags & PS_FLAG_HIT_FIRE)) { set_action_state(ACTION_STATE_IDLE); @@ -372,34 +382,33 @@ API_CALLABLE(func_802BD754_31D2C4) { return ApiStatus_DONE1; } - if (WattStaticEffect != NULL) { - WattStaticEffect->data.staticStatus->unk_04 = npc->pos.x; - WattStaticEffect->data.staticStatus->unk_08 = npc->pos.y + 13.0f; - WattStaticEffect->data.staticStatus->unk_0C = npc->pos.z; + if (N(StaticEffect) != NULL) { + N(StaticEffect)->data.staticStatus->pos.x = npc->pos.x; + N(StaticEffect)->data.staticStatus->pos.y = npc->pos.y + 13.0f; + N(StaticEffect)->data.staticStatus->pos.z = npc->pos.z; } - return ApiStatus_BLOCK; } EvtScript EVS_WorldWatt_UseAbility = { - EVT_CALL(func_802BD754_31D2C4) + EVT_CALL(N(UseAbility)) EVT_RETURN EVT_END }; -API_CALLABLE(WattPutAway) { +API_CALLABLE(N(PutAway)) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* wattActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; Npc* watt = script->owner2.npc; if (isInitialCall) { - world_watt_dispose_static_effect(); + N(dispose_static_effect)(); partner_init_put_away(watt); force_player_anim(ANIM_Mario1_Idle); - wattActionStatus->actingPartner = PARTNER_NONE; - wattActionStatus->partnerActionState = PARTNER_ACTION_NONE; + partnerStatus->actingPartner = PARTNER_NONE; + partnerStatus->partnerActionState = PARTNER_ACTION_NONE; playerStatus->animFlags &= ~(PA_FLAG_WATT_IN_HANDS | PA_FLAG_USING_WATT); - gGameStatusPtr->keepUsingPartnerOnMapChange = 0; + gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; } if (partner_put_away(watt)) { @@ -410,35 +419,35 @@ API_CALLABLE(WattPutAway) { } EvtScript EVS_WorldWatt_PutAway = { - EVT_CALL(WattPutAway) + EVT_CALL(N(PutAway)) EVT_RETURN EVT_END }; -void world_watt_pre_battle(Npc* watt) { - PartnerActionStatus* wattActionStatus = &gPartnerActionStatus; +void N(pre_battle)(Npc* watt) { + PartnerStatus* partnerStatus = &gPartnerStatus; - if (D_802BE30C != 0) { - wattActionStatus->npc = *watt; - wattActionStatus->partnerAction_unk_1 = TRUE; + if (N(IsPlayerHolding)) { + partnerStatus->npc = *watt; + partnerStatus->shouldResumeAbility = TRUE; partner_clear_player_tracking(watt); } - world_watt_dispose_static_effect(); + N(dispose_static_effect)(); } -void world_watt_post_battle(Npc* watt) { - PartnerActionStatus* wattActionStatus = &gPartnerActionStatus; +void N(post_battle)(Npc* watt) { + PartnerStatus* partnerStatus = &gPartnerStatus; - if (wattActionStatus->partnerAction_unk_1) { - *watt = wattActionStatus->npc; + if (partnerStatus->shouldResumeAbility) { + *watt = partnerStatus->npc; partner_use_ability(); - func_802BD100_31CC70(watt); + N(create_static_effect)(watt); } } -API_CALLABLE(N(Riding)) { - PartnerActionStatus* wattActionStatus = &gPartnerActionStatus; +API_CALLABLE(N(EnterMap)) { + PartnerStatus* partnerStatus = &gPartnerStatus; PlayerStatus* playerStatus = &gPlayerStatus; Npc* watt = get_npc_unsafe(NPC_PARTNER); @@ -450,28 +459,28 @@ API_CALLABLE(N(Riding)) { case 0: if (script->varTable[12] == 0) { partner_kill_ability_script(); - world_watt_dispose_static_effect(); + N(dispose_static_effect)(); } else { - func_802BD100_31CC70(watt); + N(create_static_effect)(watt); } script->functionTemp[1] = script->varTable[4]; playerStatus->targetYaw = atan2(playerStatus->position.x, playerStatus->position.z, - script->varTable[1], script->varTable[3]); + script->varTable[1], script->varTable[3]); playerStatus->heading = playerStatus->targetYaw; move_player(script->functionTemp[1], playerStatus->heading, script->varTableF[5]); - world_watt_sync_held_position(); + N(sync_held_position)(); watt->flags &= ~NPC_FLAG_GRAVITY; watt->flags |= NPC_FLAG_IGNORE_PLAYER_COLLISION; playerStatus->animFlags |= (PA_FLAG_WATT_IN_HANDS | PA_FLAG_USING_WATT); - gGameStatusPtr->keepUsingPartnerOnMapChange = 1; - wattActionStatus->partnerActionState = PARTNER_ACTION_WATT_SHINE; - wattActionStatus->actingPartner = PARTNER_WATT; - D_802BE308 = 0; + gGameStatusPtr->keepUsingPartnerOnMapChange = TRUE; + partnerStatus->partnerActionState = PARTNER_ACTION_WATT_SHINE; + partnerStatus->actingPartner = PARTNER_WATT; + N(D_802BE308) = FALSE; script->functionTemp[0]++; break; case 1: - world_watt_sync_held_position(); + N(sync_held_position)(); script->functionTemp[1]--; if (script->functionTemp[1] == 0) { if (script->varTable[12]) { @@ -485,7 +494,7 @@ API_CALLABLE(N(Riding)) { return ApiStatus_BLOCK; } -void func_802BE014_31DB84(void) { +void N(update_player_carry_anim)(void) { PlayerStatus* playerStatus = &gPlayerStatus; f32 currentSpeed = playerStatus->currentSpeed; AnimID anim; @@ -493,14 +502,14 @@ void func_802BE014_31DB84(void) { if (playerStatus->runSpeed <= currentSpeed) { anim = ANIM_MarioW1_CarryRun; } else if (playerStatus->walkSpeed <= currentSpeed) { - anim = ANIM_MarioW1_Carry; + anim = ANIM_MarioW1_CarryWalk; } else { - anim = ANIM_MarioW1_PlaceRecord; + anim = ANIM_MarioW1_CarryIdle; } suggest_player_anim_allow_backward(anim); } -void world_watt_sync_held_position(void) { +void N(sync_held_position)(void) { Npc* partnerNPC; Npc* new_var2; Camera* camera = gCameras; @@ -509,7 +518,7 @@ void world_watt_sync_held_position(void) { f32 spriteFacingAngle; s32 angleOffset; - if (gPartnerActionStatus.partnerActionState != PARTNER_ACTION_NONE) { + if (gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE) { spriteFacingAngle = gPlayerStatusPtr->spriteFacingAngle; if ((spriteFacingAngle < 90.0f) || (spriteFacingAngle > 270.0f)) { if (!(gPlayerStatusPtr->trueAnimation & SPRITE_ID_BACK_FACING)) { @@ -545,8 +554,8 @@ void world_watt_sync_held_position(void) { } } -EvtScript EVS_WorldWatt_Riding = { - EVT_CALL(N(Riding)) +EvtScript EVS_WorldWatt_EnterMap = { + EVT_CALL(N(EnterMap)) EVT_RETURN EVT_END }; diff --git a/src/world/partner/watt.h b/src/world/partner/watt.h index 26dd104283..0a1591f92b 100644 --- a/src/world/partner/watt.h +++ b/src/world/partner/watt.h @@ -8,10 +8,12 @@ void world_watt_init(Npc*); void world_watt_pre_battle(Npc*); void world_watt_post_battle(Npc*); +void world_watt_sync_held_position(void); + extern EvtScript EVS_WorldWatt_TakeOut; extern EvtScript EVS_WorldWatt_Update; extern EvtScript EVS_WorldWatt_UseAbility; extern EvtScript EVS_WorldWatt_PutAway; -extern EvtScript EVS_WorldWatt_Riding; +extern EvtScript EVS_WorldWatt_EnterMap; #endif diff --git a/src/world/partners.c b/src/world/partners.c index 941e5963c0..eaf0a442fd 100644 --- a/src/world/partners.c +++ b/src/world/partners.c @@ -269,7 +269,7 @@ WorldPartner wPartners[] = { .canPlayerPause = world_partner_can_player_pause_default, .preBattle = world_watt_pre_battle, .postBattle = world_watt_post_battle, - .whileRiding = &EVS_WorldWatt_Riding, + .onEnterMap = &EVS_WorldWatt_EnterMap, }, [PARTNER_SUSHIE] { .dmaStart = &world_partner_sushie_ROM_START, @@ -285,7 +285,7 @@ WorldPartner wPartners[] = { .canPlayerPause = world_partner_can_player_pause_default, .preBattle = world_sushie_pre_battle, .postBattle = world_sushie_post_battle, - .whileRiding = &EVS_WorldSushie_Riding, + .onEnterMap = &EVS_WorldSushie_EnterMap, }, [PARTNER_LAKILESTER] { .dmaStart = &world_partner_lakilester_ROM_START, @@ -301,7 +301,7 @@ WorldPartner wPartners[] = { .canPlayerPause = world_partner_can_player_pause_default, .preBattle = world_lakilester_pre_battle, .postBattle = world_lakilester_post_battle, - .whileRiding = &evs_worldlakilester_riding, + .onEnterMap = &EVS_WorldLakilester_EnterMap, }, [PARTNER_BOW] { .dmaStart = &world_partner_bow_ROM_START, @@ -530,7 +530,7 @@ s32 func_800EA4B0(s32 collisionID) { } s32 partner_is_idle(Npc* partner) { - return gPartnerActionStatus.partnerActionState == PARTNER_ACTION_NONE; + return gPartnerStatus.partnerActionState == PARTNER_ACTION_NONE; } s32 world_partner_can_player_pause_default(Npc* partner) { @@ -546,20 +546,25 @@ s32 func_800EA52C(s32 partnerID) { return FALSE; } - if (playerActionState == ACTION_STATE_IDLE || playerActionState == ACTION_STATE_WALK || playerActionState == ACTION_STATE_RUN) { + // any partner + if (playerActionState == ACTION_STATE_IDLE + || playerActionState == ACTION_STATE_WALK + || playerActionState == ACTION_STATE_RUN + ) { ret = TRUE; } + // check specific partners if (partnerID == PARTNER_BOW) { if (playerActionState == ACTION_STATE_RIDE) { ret = TRUE; } } else if (partnerID == PARTNER_PARAKARRY) { - if ((playerActionState != ACTION_STATE_RIDE) && (playerActionState != ACTION_STATE_IDLE) && (playerActionState != ACTION_STATE_WALK)) { - if (playerActionState == ACTION_STATE_RUN) { - ret = TRUE; - } - } else { + if (playerActionState == ACTION_STATE_RIDE + || playerActionState == ACTION_STATE_IDLE + || playerActionState == ACTION_STATE_WALK + || playerActionState == ACTION_STATE_RUN + ) { ret = TRUE; } } @@ -624,27 +629,27 @@ void _use_partner_ability(void) { static u32 PartnerCommand; // goes into BSS, needs to be static for the function to match PlayerData* playerData = &gPlayerData; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; PlayerStatus* playerStatus = &gPlayerStatus; - if (!partnerActionStatus->inputDisabled) { - partnerActionStatus->stickX = gGameStatusPtr->stickX[gGameStatusPtr->multiplayerEnabled]; - partnerActionStatus->stickY = gGameStatusPtr->stickY[gGameStatusPtr->multiplayerEnabled]; - partnerActionStatus->currentButtons = gGameStatusPtr->currentButtons[gGameStatusPtr->multiplayerEnabled]; - partnerActionStatus->pressedButtons = gGameStatusPtr->pressedButtons[gGameStatusPtr->multiplayerEnabled]; - partnerActionStatus->heldButtons = gGameStatusPtr->heldButtons[gGameStatusPtr->multiplayerEnabled]; + if (partnerStatus->inputDisabledCount == 0) { + partnerStatus->stickX = gGameStatusPtr->stickX[gGameStatusPtr->multiplayerEnabled]; + partnerStatus->stickY = gGameStatusPtr->stickY[gGameStatusPtr->multiplayerEnabled]; + partnerStatus->currentButtons = gGameStatusPtr->currentButtons[gGameStatusPtr->multiplayerEnabled]; + partnerStatus->pressedButtons = gGameStatusPtr->pressedButtons[gGameStatusPtr->multiplayerEnabled]; + partnerStatus->heldButtons = gGameStatusPtr->heldButtons[gGameStatusPtr->multiplayerEnabled]; } else { - partnerActionStatus->stickX = 0; - partnerActionStatus->stickY = 0; - partnerActionStatus->currentButtons = 0; - partnerActionStatus->pressedButtons = 0; - partnerActionStatus->heldButtons = 0; + partnerStatus->stickX = 0; + partnerStatus->stickY = 0; + partnerStatus->currentButtons = 0; + partnerStatus->pressedButtons = 0; + partnerStatus->heldButtons = 0; } if (playerStatus->animFlags & PA_FLAG_INTERRUPT_USE_PARTNER) { playerStatus->animFlags &= ~PA_FLAG_INTERRUPT_USE_PARTNER; - partnerActionStatus->pressedButtons |= BUTTON_B | BUTTON_C_DOWN; - playerStatus->animFlags |= PA_FLAG_PARTNER_USAGE_STOPPED; + partnerStatus->pressedButtons |= BUTTON_B | BUTTON_C_DOWN; + playerStatus->animFlags |= PA_FLAG_FORCED_PARTNER_ABILITY_END; } if (NextPartnerCommand != PARTNER_CMD_NONE) { @@ -687,7 +692,7 @@ void _use_partner_ability(void) { sfx_play_sound(SOUND_E); wPartner->init(wPartnerNpc); PartnerCommandState += 1; - // fall through + // fallthrough case 2: // take out new partner wPartnerCurrentScript = start_script(wPartner->takeOut, EVT_PRIORITY_14, EVT_FLAG_RUN_IMMEDIATELY); wPartnerCurrentScript->owner2.npc = wPartnerNpc; @@ -729,7 +734,7 @@ void _use_partner_ability(void) { wPartnerNpc->scale.z = 1.0f; wPartner->init(wPartnerNpc); PartnerCommandState += 1; - // fall through + // fallthrough case 2: PartnerCommandState += 1; break; @@ -782,7 +787,7 @@ void _use_partner_ability(void) { create_partner_npc(); wPartner->init(wPartnerNpc); PartnerCommandState += 1; - // fall through + // fallthrough case 1: // take out new partner wPartnerCurrentScript = start_script(wPartner->takeOut, EVT_PRIORITY_14, EVT_FLAG_RUN_IMMEDIATELY); wPartnerCurrentScript->owner2.npc = wPartnerNpc; @@ -860,12 +865,12 @@ void _use_partner_ability(void) { disable_player_input(); wPartner->init(wPartnerNpc); PartnerCommandState += 1; - // fall through + // fallthrough case 1: PartnerCommandState += 1; break; case 2: - if (partnerActionStatus->partnerActionState != 1) { + if (partnerStatus->partnerActionState != 1) { wSavedPartnerPosX = playerStatus->position.x; wSavedPartnerPosY = playerStatus->position.y; wSavedPartnerPosZ = playerStatus->position.z; @@ -919,13 +924,13 @@ void switch_to_partner(s32 partnerID) { void partner_init_after_battle(s32 partnerID) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* actionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; if (wCurrentPartnerId != partnerID) { D_8010CFE0 = 1; NextPartnerID = partnerID; - actionStatus->partnerActionState = 0; - actionStatus->partnerAction_unk_1 = FALSE; + partnerStatus->partnerActionState = 0; + partnerStatus->shouldResumeAbility = FALSE; if (wCurrentPartnerId != PARTNER_NONE && partnerID != PARTNER_NONE) { NextPartnerCommand = PARTNER_CMD_INSTA_SWITCH; @@ -956,13 +961,13 @@ void func_800EB2A4(s32 partnerID) { } s32 partner_use_ability(void) { - PartnerActionStatus* actionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; - if (!is_starting_conversation() && - wPartner != NULL && - (wPartner->canUseAbility == NULL || wPartner->canUseAbility(wPartnerNpc))) + if (!is_starting_conversation() + && wPartner != NULL + && (wPartner->canUseAbility == NULL || wPartner->canUseAbility(wPartnerNpc))) { - if (gGameStatusPtr->multiplayerEnabled && (actionStatus->currentButtons & BUTTON_B)) { + if (gGameStatusPtr->multiplayerEnabled && (partnerStatus->currentButtons & BUTTON_B)) { sfx_play_sound(SOUND_MENU_ERROR); } else if (wCurrentPartnerId != PARTNER_NONE) { D_8010CFE0 = 1; @@ -975,7 +980,10 @@ s32 partner_use_ability(void) { } s32 partner_player_can_pause(void) { - if (wPartner != NULL && wPartner->canPlayerPause != NULL && !wPartner->canPlayerPause(wPartnerNpc)) { + if (wPartner != NULL + && wPartner->canPlayerPause != NULL + && !wPartner->canPlayerPause(wPartnerNpc) + ) { return FALSE; } return TRUE; @@ -992,16 +1000,16 @@ void partner_reset_data(void) { PlayerStatus* playerStatus = &gPlayerStatus; s32 currentPartner = gPlayerData.currentPartner; - mem_clear(&gPartnerActionStatus, sizeof(gPartnerActionStatus)); + mem_clear(&gPartnerStatus, sizeof(gPartnerStatus)); get_worker(create_worker_frontUI(_use_partner_ability, NULL)); D_8010CFE0 = 1; NextPartnerCommand = PARTNER_CMD_RESET; wCurrentPartnerId = currentPartner; - if (gGameStatusPtr->keepUsingPartnerOnMapChange != 0) { - gPartnerActionStatus.partnerActionState = 1; - gGameStatusPtr->keepUsingPartnerOnMapChange = 0; + if (gGameStatusPtr->keepUsingPartnerOnMapChange) { + gPartnerStatus.partnerActionState = 1; + gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; } wPartner = NULL; @@ -1021,18 +1029,18 @@ void partner_reset_data(void) { } void partner_initialize_data(void) { - PartnerActionStatus* actionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; wCurrentPartnerId = 0; D_8010CFE0 = 0; NextPartnerCommand = PARTNER_CMD_NONE; D_8010CFC4 = 0; - actionStatus->actingPartner = 0; - actionStatus->inputDisabled = 0; - actionStatus->partnerAction_unk_1 = FALSE; - actionStatus->partnerActionState = 0; - actionStatus->unk_358 = 0; - actionStatus->partnerAction_unk_2 = 0; + partnerStatus->actingPartner = 0; + partnerStatus->inputDisabledCount = 0; + partnerStatus->shouldResumeAbility = FALSE; + partnerStatus->partnerActionState = 0; + partnerStatus->unk_358 = 0; + partnerStatus->partnerAction_unk_2 = FALSE; wPartner = NULL; wSavedPartnerPosX = 0; wSavedPartnerPosY = 0; @@ -1046,13 +1054,13 @@ s32 partner_test_enemy_collision(Npc* enemy) { return FALSE; } -EvtScript* partner_get_ride_script(void) { +EvtScript* partner_get_enter_map_script(void) { WorldPartner* partner = wPartner; if (partner == NULL) { return NULL; } - return partner->whileRiding; + return partner->onEnterMap; } void partner_handle_before_battle(void) { @@ -1070,7 +1078,7 @@ void partner_handle_before_battle(void) { } void partner_handle_after_battle(void) { - PartnerActionStatus* actionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; PlayerData* playerData = &gPlayerData; if (wCurrentPartnerId != PARTNER_NONE) { @@ -1085,10 +1093,10 @@ void partner_handle_after_battle(void) { NextPartnerCommand = PARTNER_CMD_INIT; - if (playerData->currentPartner != PARTNER_WATT && actionStatus->actingPartner == PARTNER_WATT) { + if (playerData->currentPartner != PARTNER_WATT && partnerStatus->actingPartner == PARTNER_WATT) { gPlayerStatusPtr->animFlags &= ~PA_FLAG_USING_WATT; gPlayerStatusPtr->animFlags &= ~PA_FLAG_WATT_IN_HANDS; - actionStatus->actingPartner = PARTNER_NONE; + partnerStatus->actingPartner = PARTNER_NONE; } if (wPartner->postBattle != NULL) { @@ -1192,15 +1200,15 @@ void partner_walking_update_player_tracking(Npc* partner) { void partner_walking_update_motion(Npc* partner) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* actionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; if (gGameStatusPtr->multiplayerEnabled == 0 || playerStatus->flags & (PS_FLAG_INPUT_DISABLED | PS_FLAG_NO_STATIC_COLLISION) - || actionStatus->inputDisabled != 0 || actionStatus->partnerAction_unk_2 != 0) { + || partnerStatus->inputDisabledCount != 0 || partnerStatus->partnerAction_unk_2) { if (!(playerStatus->animFlags & PA_FLAG_OPENED_HIDDEN_PANEL)) { partner_walking_follow_player(partner); } - if (actionStatus->pressedButtons & (BUTTON_Z | BUTTON_B | BUTTON_C_LEFT | BUTTON_C_DOWN)) { - actionStatus->partnerAction_unk_2 = 0; + if (partnerStatus->pressedButtons & (BUTTON_Z | BUTTON_B | BUTTON_C_LEFT | BUTTON_C_DOWN)) { + partnerStatus->partnerAction_unk_2 = FALSE; } } @@ -1594,7 +1602,7 @@ void partner_walking_follow_player(Npc* partner) { yaw = atan2(partner->pos.x, partner->pos.z, partner->moveToPos.x, partner->moveToPos.z); partner->yaw = D_800F8034 = yaw; D_8010CFCE++; - /* fallthrough */ + // fallthrough case 1: if (wPartnerMoveTime != 0) { wPartnerMoveTime--; @@ -1766,21 +1774,21 @@ void partner_flying_update_player_tracking(Npc* partner) { void partner_flying_update_motion(Npc* partner) { PlayerStatus* playerStatus = &gPlayerStatus; - PartnerActionStatus* partnerActionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; f32 x, y, z, hitDepth; f32 var_f0; f32 var_f2; if (gGameStatusPtr->multiplayerEnabled == 0 || (playerStatus->flags & (PS_FLAG_INPUT_DISABLED | PS_FLAG_NO_STATIC_COLLISION)) || - partnerActionStatus->inputDisabled || - partnerActionStatus->partnerAction_unk_2 != 0) + partnerStatus->inputDisabledCount || + partnerStatus->partnerAction_unk_2) { if (!(playerStatus->animFlags & PA_FLAG_OPENED_HIDDEN_PANEL) || D_800F8020 == 0) { partner_flying_follow_player(partner); } - if (partnerActionStatus->pressedButtons & (BUTTON_B | BUTTON_Z | BUTTON_C_DOWN | BUTTON_C_LEFT)) { - partnerActionStatus->partnerAction_unk_2 = 0; + if (partnerStatus->pressedButtons & (BUTTON_B | BUTTON_Z | BUTTON_C_DOWN | BUTTON_C_LEFT)) { + partnerStatus->partnerAction_unk_2 = FALSE; } } if (wPartnerFollowState != 50 && fabsf(partner->pos.y - playerStatus->position.y) > 1000.0f) { @@ -2115,7 +2123,7 @@ void partner_flying_follow_player(Npc* partner) { yaw = atan2(partner->pos.x, partner->pos.z, partner->moveToPos.x, partner->moveToPos.z); partner->yaw = D_800F8034 = yaw; D_8010CFCE++; - /* fallthrough */ + // fallthrough case 1: if (wPartnerMoveTime != 0) { x = partner->pos.x; @@ -2135,7 +2143,7 @@ void partner_flying_follow_player(Npc* partner) { x = partner->pos.x; y = partner->pos.y; z = partner->pos.z; - if (npc_test_move_taller_with_slipping(0, &x, &y, &z, partner->moveSpeed, partner->yaw, partner->collisionHeight, partner->collisionRadius) != 0) { + if (npc_test_move_taller_with_slipping(0, &x, &y, &z, partner->moveSpeed, partner->yaw, partner->collisionHeight, partner->collisionRadius)) { partner->pos.x += (x - partner->pos.x) / 5.0f; partner->pos.z += (z - partner->pos.z) / 5.0f; } else { @@ -2470,18 +2478,18 @@ s32 partner_force_player_flip_done(void) { } void partner_enable_input(void) { - PartnerActionStatus* actionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; - actionStatus->inputDisabled--; - if (actionStatus->inputDisabled < 0) { - actionStatus->inputDisabled = 0; + partnerStatus->inputDisabledCount--; + if (partnerStatus->inputDisabledCount < 0) { + partnerStatus->inputDisabledCount = 0; } } void partner_disable_input(void) { - PartnerActionStatus* actionStatus = &gPartnerActionStatus; + PartnerStatus* partnerStatus = &gPartnerStatus; - actionStatus->inputDisabled++; + partnerStatus->inputDisabledCount++; } void partner_do_player_collision(Npc* partner) { diff --git a/src/world/partners.h b/src/world/partners.h index a88a4d6723..b2a9e2c303 100644 --- a/src/world/partners.h +++ b/src/world/partners.h @@ -21,7 +21,7 @@ typedef struct WorldPartner { /* 0x30 */ PartnerBoolFunc canPlayerPause; /* 0x34 */ PartnerFunc preBattle; /* 0x38 */ PartnerFunc postBattle; - /* 0x3C */ EvtScript* whileRiding; + /* 0x3C */ EvtScript* onEnterMap; } WorldPartner; // size = 0x40 extern Npc* wPartnerNpc; // wPartnerNpc diff --git a/src/world/script_api/enter_exit.c b/src/world/script_api/enter_exit.c index 4228da4f37..1cddd6c614 100644 --- a/src/world/script_api/enter_exit.c +++ b/src/world/script_api/enter_exit.c @@ -4,16 +4,16 @@ extern s32 DoorModelsSwingCCW[3]; extern s32 DoorModelsSwingCW[3]; -API_CALLABLE(CheckRideScriptForEnterExit) { +API_CALLABLE(CheckUsingRideablePartner) { PlayerStatus* playerStatus = &gPlayerStatus; script->varTable[10] = 0; - if (partner_get_ride_script() != NULL) { - if (gPartnerActionStatus.partnerActionState == ACTION_STATE_IDLE) { + if (partner_get_enter_map_script() != NULL) { + if (gPartnerStatus.partnerActionState == ACTION_STATE_IDLE) { script->varTable[10] = 0; } else { script->varTable[10] = 1; - script->varTablePtr[11] = partner_get_ride_script(); + script->varTablePtr[11] = partner_get_enter_map_script(); script->varTable[13] = playerStatus->targetYaw; } } @@ -199,7 +199,7 @@ API_CALLABLE(SetupSplitDoubleDoors) { EvtScript EnterWalk = { EVT_CALL(ShortenPartnerTetherDistance) - EVT_CALL(CheckRideScriptForEnterExit) + EVT_CALL(CheckUsingRideablePartner) EVT_CALL(UseEntryHeading, 60, 15) EVT_IF_EQ(LVarA, 0) EVT_CALL(TeleportPartnerToPlayer) @@ -221,7 +221,7 @@ EvtScript EnterWalk = { EvtScript EnterWalkShort = { EVT_CALL(ShortenPartnerTetherDistance) - EVT_CALL(CheckRideScriptForEnterExit) + EVT_CALL(CheckUsingRideablePartner) EVT_CALL(UseEntryHeading, 40, 15) EVT_IF_EQ(LVarA, 0) EVT_CALL(TeleportPartnerToPlayer) @@ -243,7 +243,7 @@ EvtScript EnterWalkShort = { EvtScript EnterWalkCustom = { EVT_CALL(ShortenPartnerTetherDistance) - EVT_CALL(CheckRideScriptForEnterExit) + EVT_CALL(CheckUsingRideablePartner) EVT_CALL(UseEntryHeading, LVar1, LVar4) EVT_IF_EQ(LVarA, 0) EVT_CALL(TeleportPartnerToPlayer) @@ -265,7 +265,7 @@ EvtScript EnterWalkCustom = { EvtScript EnterPostPipe = { EVT_CALL(DisablePlayerPhysics, TRUE) EVT_CALL(ShortenPartnerTetherDistance) - EVT_CALL(CheckRideScriptForEnterExit) + EVT_CALL(CheckUsingRideablePartner) EVT_CALL(EnterPlayerPostPipe) EVT_CALL(ResetPartnerTetherDistance) EVT_CALL(DisablePlayerPhysics, FALSE) @@ -285,7 +285,7 @@ EvtScript EnterSavePoint = { EvtScript ExitWalk = { EVT_CALL(DisablePlayerInput, TRUE) EVT_CALL(ShortenPartnerTetherDistance) - EVT_CALL(CheckRideScriptForEnterExit) + EVT_CALL(CheckUsingRideablePartner) EVT_IF_EQ(LVarA, 0) EVT_CALL(PlayerMoveTo, LVar1, LVar3, 15) EVT_ELSE @@ -364,7 +364,7 @@ EvtScript BaseExitDoor = { EVT_ADD(LVarB, 180) EVT_CALL(InterpPlayerYaw, LVarB, 2) EVT_CALL(ModifyColliderFlags, 0, LVar1, COLLIDER_FLAGS_UPPER_MASK) - EVT_CALL(PlaySoundAt, 0x90000000, 0, LVarC, LVarD, LVarE) + EVT_CALL(PlaySoundAt, SOUND_DOOR_OPEN, 0, LVarC, LVarD, LVarE) EVT_CALL(MakeLerp, 0, 80, 10, EASING_LINEAR) EVT_LABEL(0) EVT_CALL(UpdateLerp) @@ -389,7 +389,7 @@ EvtScript BaseExitDoor = { EVT_GOTO(0) EVT_END_IF EVT_CALL(UseExitHeading, 40, LVar9) - EVT_CALL(CheckRideScriptForEnterExit) + EVT_CALL(CheckUsingRideablePartner) EVT_IF_EQ(LVarA, 0) EVT_CALL(PlayerMoveTo, LVar1, LVar3, 15) EVT_ELSE @@ -426,7 +426,7 @@ EvtScript BaseEnterDoor = { EVT_END_LOOP EVT_CALL(GetEntryCoords, LVar0, LVar7, LVar8, LVar9, LVarB) EVT_CALL(InterpPlayerYaw, LVarB, 2) - EVT_CALL(CheckRideScriptForEnterExit) + EVT_CALL(CheckUsingRideablePartner) EVT_IF_EQ(LVarA, 0) EVT_CALL(TeleportPartnerToPlayer) EVT_CALL(PlayerMoveToDoor, 10) @@ -438,7 +438,7 @@ EvtScript BaseEnterDoor = { EVT_END_IF EVT_THREAD EVT_WAIT(8) - EVT_CALL(PlaySoundAt, 0x90000001, 0, LVar7, LVar8, LVar9) + EVT_CALL(PlaySoundAt, SOUND_DOOR_CLOSE, 0, LVar7, LVar8, LVar9) EVT_END_THREAD EVT_CALL(MakeLerp, -80, 0, 10, EASING_LINEAR) EVT_LABEL(0) diff --git a/ver/ique/asm/nonmatchings/C50A0/test_item_player_collision.s b/ver/ique/asm/nonmatchings/C50A0/test_item_player_collision.s index 5072d67363..2630b14c4a 100644 --- a/ver/ique/asm/nonmatchings/C50A0/test_item_player_collision.s +++ b/ver/ique/asm/nonmatchings/C50A0/test_item_player_collision.s @@ -11,8 +11,8 @@ glabel test_item_player_collision /* C918C 801322AC 3C118011 */ lui $s1, %hi(gPlayerStatus) /* C9190 801322B0 2631D3A8 */ addiu $s1, $s1, %lo(gPlayerStatus) /* C9194 801322B4 AFB40038 */ sw $s4, 0x38($sp) -/* C9198 801322B8 3C148011 */ lui $s4, %hi(gPartnerActionStatus) -/* C919C 801322BC 2694CF90 */ addiu $s4, $s4, %lo(gPartnerActionStatus) +/* C9198 801322B8 3C148011 */ lui $s4, %hi(gPartnerStatus) +/* C919C 801322BC 2694CF90 */ addiu $s4, $s4, %lo(gPartnerStatus) /* C91A0 801322C0 3C038007 */ lui $v1, %hi(gCurrentCameraID) /* C91A4 801322C4 8C636070 */ lw $v1, %lo(gCurrentCameraID)($v1) /* C91A8 801322C8 3C04800B */ lui $a0, %hi(gCameras) diff --git a/ver/ique/symbol_addrs.txt b/ver/ique/symbol_addrs.txt index e5422f34ad..a7c2ae38c8 100644 --- a/ver/ique/symbol_addrs.txt +++ b/ver/ique/symbol_addrs.txt @@ -63,7 +63,7 @@ D_800A08E8 = 0x8009d2f8; D_800A08EC = 0x8009d2fc; gNpcPlayerCollisionsEnabled = 0x8009d5a4; wPartnerNpc = 0x8010ad10; -gPartnerActionStatus = 0x8010cf90; +gPartnerStatus = 0x8010cf90; gPlayerStatus = 0x8010d3a8; get_clamped_angle_diff = 0x800298f8; get_npc_by_index = 0x8003818c; diff --git a/ver/ique/undefined_syms.txt b/ver/ique/undefined_syms.txt index 0ec4f3622d..cc18b34dd4 100644 --- a/ver/ique/undefined_syms.txt +++ b/ver/ique/undefined_syms.txt @@ -794,7 +794,7 @@ HES_MoveDiamondDisabled = 0x801077b8; HES_MoveDiamond = 0x80107718; npc_test_move_simple_with_slipping = 0x800dc024; SetNpcPos = 0x802cdcb0; -gPartnerActionStatus = 0x8010cf90; +gPartnerStatus = 0x8010cf90; SetNpcAnimation = 0x802ce0f4; GetNpcPos = 0x802cf0f4; partner_reset_data = 0x800e9854; @@ -901,7 +901,7 @@ D_800A08E8 = 0x8009d2f8; D_800A08EC = 0x8009d2fc; gNpcPlayerCollisionsEnabled = 0x8009d5a4; wPartnerNpc = 0x8010ad10; -gPartnerActionStatus = 0x8010cf90; +gPartnerStatus = 0x8010cf90; gPlayerStatus = 0x8010d3a8; D_801A6000 = 0x801a6000; diff --git a/ver/jp/symbol_addrs.txt b/ver/jp/symbol_addrs.txt index ba1b62e3ca..55f8e1033f 100644 --- a/ver/jp/symbol_addrs.txt +++ b/ver/jp/symbol_addrs.txt @@ -253,7 +253,7 @@ player_render_interact_prompts = 0x800E0240; render_player = 0x800E1118; clear_player_data = 0x800E7340; wPartnerNpc = 0x8010CAF0; -gPartnerActionStatus = 0x8010ED70; +gPartnerStatus = 0x8010ED70; gPlayerStatus = 0x8010F188; gPlayerData = 0x8010F450; spr_init_sprites = 0x80111448; diff --git a/ver/jp/undefined_syms.txt b/ver/jp/undefined_syms.txt index 973b087858..c85fadb430 100644 --- a/ver/jp/undefined_syms.txt +++ b/ver/jp/undefined_syms.txt @@ -144,7 +144,7 @@ HES_MoveDiamond = 0x801094C8; HES_MoveDiamondDisabled = 0x80109568; wPartnerNpc = 0x8010CAF0; NpcHitQueryColliderID = 0x8010CB38; -gPartnerActionStatus = 0x08010ED70; +gPartnerStatus = 0x08010ED70; gPlayerStatus = 0x8010F188; gPlayerData = 0x8010F450; spr_init_sprites = 0x80111448; diff --git a/ver/pal/undefined_syms.txt b/ver/pal/undefined_syms.txt index eb7bd98aae..928a7b87d6 100644 --- a/ver/pal/undefined_syms.txt +++ b/ver/pal/undefined_syms.txt @@ -235,7 +235,7 @@ set_max_SP = 0x800E6A30; subtract_hp = 0x800E6B8C; switch_to_partner = 0x800E79B8; func_800EB2A4 = 0x800E7AF4; -partner_get_ride_script = 0x800E7E88; +partner_get_enter_map_script = 0x800E7E88; partner_suspend_ability_script = 0x800E8068; partner_resume_ability_script = 0x800E80B0; func_800EF300 = 0x800EBB50; @@ -262,7 +262,7 @@ HES_RunAwayOK = 0x80107DEC; ui_box_corners5_png = 0x80109D00; wPartnerNpc = 0x8010B420; NpcHitQueryColliderID = 0x8010B468; -gPartnerActionStatus = 0x8010D6B0; +gPartnerStatus = 0x8010D6B0; gPlayerStatus = 0x8010DAC8; gPlayerData = 0x8010DD90; exec_entity_commandlist = 0x8010E868; diff --git a/ver/us/asm/bss2_2.s b/ver/us/asm/bss2_2.s index 57eb0ece54..7b99643372 100644 --- a/ver/us/asm/bss2_2.s +++ b/ver/us/asm/bss2_2.s @@ -190,7 +190,7 @@ dlabel D_8010D6A8 dlabel gBoxQuadBuffer .space 0x1500 -dlabel gPartnerActionStatus +dlabel gPartnerStatus .space 0x360 dlabel gSpinHistoryPosY diff --git a/ver/us/asm/nonmatchings/C50A0/test_item_player_collision.s b/ver/us/asm/nonmatchings/C50A0/test_item_player_collision.s index c5c0940c7f..f2a11adcfb 100644 --- a/ver/us/asm/nonmatchings/C50A0/test_item_player_collision.s +++ b/ver/us/asm/nonmatchings/C50A0/test_item_player_collision.s @@ -9,8 +9,8 @@ glabel test_item_player_collision /* CA21C 80133B1C 3C118011 */ lui $s1, %hi(gPlayerStatus) /* CA220 80133B20 2631EFC8 */ addiu $s1, $s1, %lo(gPlayerStatus) /* CA224 80133B24 AFB40038 */ sw $s4, 0x38($sp) -/* CA228 80133B28 3C148011 */ lui $s4, %hi(gPartnerActionStatus) -/* CA22C 80133B2C 2694EBB0 */ addiu $s4, $s4, %lo(gPartnerActionStatus) +/* CA228 80133B28 3C148011 */ lui $s4, %hi(gPartnerStatus) +/* CA22C 80133B2C 2694EBB0 */ addiu $s4, $s4, %lo(gPartnerStatus) /* CA230 80133B30 3C038007 */ lui $v1, %hi(gCurrentCameraID) /* CA234 80133B34 8C637410 */ lw $v1, %lo(gCurrentCameraID)($v1) /* CA238 80133B38 3C04800B */ lui $a0, %hi(gCameras) diff --git a/ver/us/symbol_addrs.txt b/ver/us/symbol_addrs.txt index b8ca8b188c..e47e5710c1 100644 --- a/ver/us/symbol_addrs.txt +++ b/ver/us/symbol_addrs.txt @@ -2978,7 +2978,7 @@ partner_can_use_ability = 0x800EB42C; // type:func rom:0x848DC partner_reset_data = 0x800EB474; // type:func rom:0x84924 partner_initialize_data = 0x800EB580; // type:func rom:0x84A30 partner_test_enemy_collision = 0x800EB5E4; // type:func rom:0x84A94 -partner_get_ride_script = 0x800EB638; // type:func rom:0x84AE8 +partner_get_enter_map_script = 0x800EB638; // type:func rom:0x84AE8 partner_handle_before_battle = 0x800EB658; // type:func rom:0x84B08 partner_handle_after_battle = 0x800EB6C4; // type:func rom:0x84B74 partner_kill_ability_script = 0x800EB7CC; // type:func rom:0x84C7C @@ -3948,7 +3948,7 @@ load_split_entity_data = 0x80111408; // type:func rom:0xA7B08 func_80111790 = 0x80111790; // type:func rom:0xA7E90 entity_free_static_data = 0x801117DC; // type:func rom:0xA7EDC create_entity = 0x801118C4; // type:func rom:0xA7FC4 -gPartnerActionStatus = 0x8010EBB0; // type:data rom:0xA8060 size:0x35C +gPartnerStatus = 0x8010EBB0; // type:data rom:0xA8060 size:0x35C create_shadow_from_data = 0x80111BD8; // type:func rom:0xA82D8 gSpinHistoryPosY = 0x8010EF10; // type:data rom:0xA83C0 gSpinHistoryPosX = 0x8010EF28; // type:data rom:0xA83D8 @@ -7743,11 +7743,11 @@ D_802BEB10_31B080 = 0x802BEB10; // type:data rom:0x31B080 D_802BEB98_31B108 = 0x802BEB98; // type:data rom:0x31B108 D_802BEBA0_31B110 = 0x802BEBA0; // type:data rom:0x31B110 D_802BEBA8_31B118 = 0x802BEBA8; // type:data rom:0x31B118 -kooper_lateral_hit_interactable_entity = 0x802BD100; // type:func rom:0x31B120 +world_kooper_lateral_hit_interactable_entity = 0x802BD100; // type:func rom:0x31B120 world_parakarry_LockingPlayerInput = 0x802BEBB4; // type:data rom:0x31B124 world_parakarry_PlayerCollisionDisabled = 0x802BEBB8; // type:data rom:0x31B128 world_parakarry_PlayerWasFacingLeft = 0x802BEBBC; // type:data rom:0x31B12C -world_parakarry_UseAbilityState = 0x802BEBC0; // type:data rom:0x31B130 +world_parakarry_AbilityState = 0x802BEBC0; // type:data rom:0x31B130 world_parakarry_AbilityStateTime = 0x802BEBC4; // type:data rom:0x31B134 ParakarryTweesterPhysics = 0x802BEBC8; // type:data rom:0x31B138 world_kooper_vertical_hit_interactable_entity = 0x802BD144; // type:func rom:0x31B164 @@ -7773,7 +7773,6 @@ D_802BEC28_31CC48 = 0x802BEC28; // type:data rom:0x31CC48 D_802BEC30_31CC50 = 0x802BEC30; // type:data rom:0x31CC50 D_802BEC38_31CC58 = 0x802BEC38; // type:data rom:0x31CC58 D_802BEC40_31CC60 = 0x802BEC40; // type:data rom:0x31CC60 -func_802BD100_31CC70 = 0x802BD100; // type:func rom:0x31CC70 world_kooper_TriggeredBattle = 0x802BEC54; // type:data rom:0x31CC74 world_kooper_PlayerWasFacingLeft = 0x802BEC58; // type:data rom:0x31CC78 world_kooper_D_802BEC5C = 0x802BEC5C; // type:data rom:0x31CC7C @@ -7786,111 +7785,110 @@ world_kooper_ShellTossPosY = 0x802BEC74; // type:data rom:0x31CC94 world_kooper_ShellTossPosZ = 0x802BEC78; // type:data rom:0x31CC98 world_kooper_D_802BEC7C = 0x802BEC7C; // type:data rom:0x31CC9C world_kooper_TweesterPhysics = 0x802BEC80; // type:data rom:0x31CCA0 +world_watt_create_static_effect = 0x802BD100; // type:func rom:0x31CC70 world_watt_dispose_static_effect = 0x802BD180; // type:func rom:0x31CCF0 -func_802BD1AC_31CD1C = 0x802BD1AC; // type:func rom:0x31CD1C +world_watt_reset_static_effect = 0x802BD1AC; // type:func rom:0x31CD1C world_watt_init = 0x802BD23C; // type:func rom:0x31CDAC -func_802BD27C_31CDEC = 0x802BD27C; // type:func rom:0x31CDEC +world_watt_TakeOut = 0x802BD27C; // type:func rom:0x31CDEC world_watt_Update = 0x802BD2B4; // type:func rom:0x31CE24 -func_802BD710_31D280 = 0x802BD710; // type:func rom:0x31D280 -func_802BD754_31D2C4 = 0x802BD754; // type:func rom:0x31D2C4 +world_watt_try_cancel_tweester = 0x802BD710; // type:func rom:0x31D280 +world_watt_UseAbility = 0x802BD754; // type:func rom:0x31D2C4 world_watt_PutAway = 0x802BDD0C; // type:func rom:0x31D87C world_watt_pre_battle = 0x802BDD9C; // type:func rom:0x31D90C world_watt_post_battle = 0x802BDE10; // type:func rom:0x31D980 -world_watt_Riding = 0x802BDE88; // type:func rom:0x31D9F8 -func_802BE014_31DB84 = 0x802BE014; // type:func rom:0x31DB84 +world_watt_EnterMap = 0x802BDE88; // type:func rom:0x31D9F8 +world_watt_update_player_carry_anim = 0x802BE014; // type:func rom:0x31DB84 world_watt_sync_held_position = 0x802BE070; // type:func rom:0x31DBE0 -D_802BE250_31DDC0 = 0x802BE250; // type:data rom:0x31DDC0 -D_802BE254_31DDC4 = 0x802BE254; // type:data rom:0x31DDC4 +world_watt_EffectAnimLengths = 0x802BE250; // type:data rom:0x31DDC0 EVS_WorldWatt_TakeOut = 0x802BE258; // type:data rom:0x31DDC8 WattTweesterPhysicsPtr = 0x802BE274; // type:data rom:0x31DDE4 -D_802BE278_31DDE8 = 0x802BE278; // type:data rom:0x31DDE8 +world_watt_WattIsMoving = 0x802BE278; // type:data rom:0x31DDE8 EVS_WorldWatt_Update = 0x802BE27C; // type:data rom:0x31DDEC EVS_WorldWatt_UseAbility = 0x802BE298; // type:data rom:0x31DE08 EVS_WorldWatt_PutAway = 0x802BE2B4; // type:data rom:0x31DE24 -EVS_WorldWatt_Riding = 0x802BE2D0; // type:data rom:0x31DE40 -func_802BD100_31DE70 = 0x802BD100; // type:func rom:0x31DE70 -D_802BE304 = 0x802BE304; // type:data rom:0x31DE74 -D_802BE308 = 0x802BE308; // type:data rom:0x31DE78 -D_802BE30C = 0x802BE30C; // type:data rom:0x31DE7C -WattStaticEffect = 0x802BE310; // type:data rom:0x31DE80 -D_802BE314 = 0x802BE314; // type:data rom:0x31DE84 +EVS_WorldWatt_EnterMap = 0x802BE2D0; // type:data rom:0x31DE40 +world_watt_AbilityState = 0x802BE304; // type:data rom:0x31DE74 +world_watt_D_802BE308 = 0x802BE308; // type:data rom:0x31DE78 +world_watt_IsPlayerHolding = 0x802BE30C; // type:data rom:0x31DE7C +world_watt_StaticEffect = 0x802BE310; // type:data rom:0x31DE80 +world_watt_D_802BE314 = 0x802BE314; // type:data rom:0x31DE84 WattTweesterPhysics = 0x802BE318; // type:data rom:0x31DE88 -func_802BD20C_31DF7C = 0x802BD20C; // type:func rom:0x31DF7C -func_802BD368_31E0D8 = 0x802BD368; // type:func rom:0x31E0D8 -func_802BD414_31E184 = 0x802BD414; // type:func rom:0x31E184 -func_802BE280_31EFF0 = 0x802BE280; // type:func rom:0x31EFF0 -func_802BE3A4_31F114 = 0x802BE3A4; // type:func rom:0x31F114 +world_sushie_sync_player_position = 0x802BD100; // type:func rom:0x31DE70 +world_sushie_get_movement_from_input = 0x802BD20C; // type:func rom:0x31DF7C +world_sushie_test_for_water_level = 0x802BD368; // type:func rom:0x31E0D8 +world_sushie_update_riding_physics = 0x802BD414; // type:func rom:0x31E184 +world_sushie_test_ray_to_wall_center = 0x802BE280; // type:func rom:0x31EFF0 +world_sushie_UseAbility = 0x802BE3A4; // type:func rom:0x31F114 world_sushie_init = 0x802BF520; // type:func rom:0x320290 -SushieTakeOut = 0x802BF568; // type:func rom:0x3202D8 -SushieUpdate = 0x802BF5A0; // type:func rom:0x320310 -func_802BF920_320690 = 0x802BF920; // type:func rom:0x320690 -SushiePutAway = 0x802BF964; // type:func rom:0x3206D4 +world_sushie_TakeOut = 0x802BF568; // type:func rom:0x3202D8 +world_sushie_Update = 0x802BF5A0; // type:func rom:0x320310 +world_sushie_try_cancel_tweester = 0x802BF920; // type:func rom:0x320690 +world_sushie_PutAway = 0x802BF964; // type:func rom:0x3206D4 world_sushie_pre_battle = 0x802BF9B8; // type:func rom:0x320728 world_sushie_post_battle = 0x802BFA58; // type:func rom:0x3207C8 -func_802BFAB8_320828 = 0x802BFAB8; // type:func rom:0x320828 -D_802BFDB0_320B20 = 0x802BFDB0; // type:data rom:0x320B20 -D_802BFDB4_320B24 = 0x802BFDB4; // type:data rom:0x320B24 -D_802BFDB8_320B28 = 0x802BFDB8; // type:data rom:0x320B28 -D_802BFDBC_320B2C = 0x802BFDBC; // type:data rom:0x320B2C +world_sushie_EnterMap = 0x802BFAB8; // type:func rom:0x320828 +world_sushie_D_802BFDB0_320B20 = 0x802BFDB0; // type:data rom:0x320B20 +world_sushie_D_802BFDB4_320B24 = 0x802BFDB4; // type:data rom:0x320B24 +world_sushie_InertialStickX = 0x802BFDB8; // type:data rom:0x320B28 +world_sushie_InertialStickY = 0x802BFDBC; // type:data rom:0x320B2C EVS_WorldSushie_UseAbility = 0x802BFDC0; // type:data rom:0x320B30 EVS_WorldSushie_TakeOut = 0x802BFDDC; // type:data rom:0x320B4C -SushieTweesterPhysicsPtr = 0x802BFDF8; // type:data rom:0x320B68 +world_sushie_TweesterPhysicsPtr = 0x802BFDF8; // type:data rom:0x320B68 EVS_WorldSushie_Update = 0x802BFDFC; // type:data rom:0x320B6C EVS_WorldSushie_PutAway = 0x802BFE18; // type:data rom:0x320B88 -EVS_WorldSushie_Riding = 0x802BFE34; // type:data rom:0x320BA4 +EVS_WorldSushie_EnterMap = 0x802BFE34; // type:data rom:0x320BA4 D_802BFE50_320BC0 = 0x802BFE50; // type:data rom:0x320BC0 D_802BFE58_320BC8 = 0x802BFE58; // type:data rom:0x320BC8 D_802BFE60_320BD0 = 0x802BFE60; // type:data rom:0x320BD0 D_802BFED0_320C40 = 0x802BFED0; // type:data rom:0x320C40 D_802BFED8_320C48 = 0x802BFED8; // type:data rom:0x320C48 -func_802BD100_320C50 = 0x802BD100; // type:func rom:0x320C50 -bss_802BFEE4 = 0x802BFEE4; // type:data rom:0x320C54 -bss_802BFEE8 = 0x802BFEE8; // type:data rom:0x320C58 -D_802BFEEC = 0x802BFEEC; // type:data rom:0x320C5C -bss_802BFEF0 = 0x802BFEF0; // type:data rom:0x320C60 -bss_802BFEF4 = 0x802BFEF4; // type:data rom:0x320C64 -D_802BFEF8 = 0x802BFEF8; // type:data rom:0x320C68 -bss_802BFEFC = 0x802BFEFC; // type:data rom:0x320C6C -bss_802BFF00 = 0x802BFF00; // type:data rom:0x320C70 -bss_802BFF04 = 0x802BFF04; // type:data rom:0x320C74 -bss_802BFF08 = 0x802BFF08; // type:data rom:0x320C78 -bss_802BFF0C = 0x802BFF0C; // type:data rom:0x320C7C +world_lakilester_sync_player_position = 0x802BD100; // type:func rom:0x320C50 +world_sushie_DiveState = 0x802BFEE4; // type:data rom:0x320C54 +world_sushie_DiveTime = 0x802BFEE8; // type:data rom:0x320C58 +world_sushie_IsRiding = 0x802BFEEC; // type:data rom:0x320C5C +world_sushie_TouchDockTime = 0x802BFEF0; // type:data rom:0x320C60 +world_sushie_IsUnderwater = 0x802BFEF4; // type:data rom:0x320C64 +world_sushie_InertialMoveSpeed = 0x802BFEF8; // type:data rom:0x320C68 +world_sushie_InertialMoveAngle = 0x802BFEFC; // type:data rom:0x320C6C +world_sushie_UnusedMoveX = 0x802BFF00; // type:data rom:0x320C70 +world_sushie_UnusedMoveZ = 0x802BFF04; // type:data rom:0x320C74 +world_sushie_ResurfaceVelY = 0x802BFF08; // type:data rom:0x320C78 +world_sushie_bss_802BFF0C = 0x802BFF0C; // type:data rom:0x320C7C SushieTweesterPhysics = 0x802BFF10; // type:data rom:0x320C80 world_lakilester_init = 0x802BD21C; // type:func rom:0x320D6C -func_802BD29C_320DEC = 0x802BD29C; // type:func rom:0x320DEC -func_802BD2D4_320E24 = 0x802BD2D4; // type:func rom:0x320E24 -lakilester_try_cancel_tweester = 0x802BD678; // type:func rom:0x3211C8 -func_802BD6BC_32120C = 0x802BD6BC; // type:func rom:0x32120C -func_802BD7DC = 0x802BD7DC; // type:func rom:0x32132C -func_802BD99C_3214EC = 0x802BD99C; // type:func rom:0x3214EC -func_802BDA90_3215E0 = 0x802BDA90; // type:func rom:0x3215E0 -func_802BDDD8_321928 = 0x802BDDD8; // type:func rom:0x321928 -func_802BE6A0_3221F0 = 0x802BE6A0; // type:func rom:0x3221F0 -LakilesterUseAbility = 0x802BE724; // type:func rom:0x322274 -func_802BF4F0_323040 = 0x802BF4F0; // type:func rom:0x323040 +world_lakilester_TakeOut = 0x802BD29C; // type:func rom:0x320DEC +world_lakilester_Update = 0x802BD2D4; // type:func rom:0x320E24 +world_lakilester_try_cancel_tweester = 0x802BD678; // type:func rom:0x3211C8 +world_lakilester_get_movement_from_input = 0x802BD6BC; // type:func rom:0x32120C +world_lakilester_test_mounting_height_adjustment = 0x802BD99C; // type:func rom:0x3214EC +world_lakilester_apply_riding_static_collisions = 0x802BDA90; // type:func rom:0x3215E0 +world_lakilester_update_riding_physics = 0x802BDDD8; // type:func rom:0x321928 +world_lakilester_test_dismount_height = 0x802BE6A0; // type:func rom:0x3221F0 +world_lakilester_UseAbility = 0x802BE724; // type:func rom:0x322274 +world_lakilester_PutAway = 0x802BF4F0; // type:func rom:0x323040 world_lakilester_pre_battle = 0x802BFA00; // type:func rom:0x323550 world_lakilester_post_battle = 0x802BFAA8; // type:func rom:0x3235F8 -func_802BFB44_323694 = 0x802BFB44; // type:func rom:0x323694 -func_802BFBA0_3236F0 = 0x802BFBA0; // type:func rom:0x3236F0 +world_lakilester_offset_player_from_camera = 0x802BFB44; // type:func rom:0x323694 +world_lakilester_EnterMap = 0x802BFBA0; // type:func rom:0x3236F0 EVS_WorldLakilester_TakeOut = 0x802BFE60; // type:data rom:0x3239B0 LakilesterTweesterPhysicsPtr = 0x802BFE7C; // type:data rom:0x3239CC EVS_WorldLakilester_Update = 0x802BFE80; // type:data rom:0x3239D0 EVS_WorldLakilester_UseAbility = 0x802BFE9C; // type:data rom:0x3239EC EVS_WorldLakilester_PutAway = 0x802BFEB8; // type:data rom:0x323A08 -evs_worldlakilester_riding = 0x802BFED4; // type:data rom:0x323A24 +EVS_WorldLakilester_EnterMap = 0x802BFED4; // type:data rom:0x323A24 D_802BFEF8_323A48 = 0x802BFEF8; // type:data rom:0x323A48 -world_bow_init = 0x802BFF00; // type:data rom:0x323A50 -D_802BFF04 = 0x802BFF04; // type:data rom:0x323A54 -D_802BFF08 = 0x802BFF08; // type:data rom:0x323A58 -D_802BFF0C = 0x802BFF0C; // type:data rom:0x323A5C -D_802BFF10 = 0x802BFF10; // type:data rom:0x323A60 -D_802BFF14 = 0x802BFF14; // type:data rom:0x323A64 -D_802BFF18 = 0x802BFF18; // type:data rom:0x323A68 -D_802BFF1C = 0x802BFF1C; // type:data rom:0x323A6C -D_802BFF20 = 0x802BFF20; // type:data rom:0x323A70 -D_802BFF24 = 0x802BFF24; // type:data rom:0x323A74 -D_802BFF28 = 0x802BFF28; // type:data rom:0x323A78 -D_802BFF2C = 0x802BFF2C; // type:data rom:0x323A7C +world_lakilester_PutAwayState = 0x802BFF00; // type:data rom:0x323A50 +world_lakilester_LockingPlayerInput = 0x802BFF04; // type:data rom:0x323A54 +world_lakilester_PlayerCollisionDisabled = 0x802BFF08; // type:data rom:0x323A58 +world_lakilester_D_802BFF0C = 0x802BFF0C; // type:data rom:0x323A5C +world_lakilester_UpdatePushingWall = 0x802BFF10; // type:data rom:0x323A60 +world_lakilester_AbilityState = 0x802BFF14; // type:data rom:0x323A64 +world_lakilester_PlayerBounceOffset = 0x802BFF18; // type:data rom:0x323A68 +world_lakilester_MoveSoundsTime = 0x802BFF1C; // type:data rom:0x323A6C +world_lakilester_MovePitchAdjustment = 0x802BFF20; // type:data rom:0x323A70 +world_lakilester_MountingDeltaY = 0x802BFF24; // type:data rom:0x323A74 +world_lakilester_CurrentGroundPitch = 0x802BFF28; // type:data rom:0x323A78 +world_lakilester_D_802BFF2C = 0x802BFF2C; // type:data rom:0x323A7C world_bow_TakeOut = 0x802BD130; // type:func rom:0x323A80 world_bow_Update = 0x802BD168; // type:func rom:0x323AB8 world_bow_try_cancel_tweester = 0x802BD4FC; // type:func rom:0x323E4C @@ -15022,7 +15020,7 @@ SetPushBlock = 0x8028347C; // type:func rom:0x7E42FC GetPushBlock = 0x802835C0; // type:func rom:0x7E4440 GetGridIndexFromPos = 0x802836B8; // type:func rom:0x7E4538 SetPushBlockFallEffect = 0x802837AC; // type:func rom:0x7E462C -CheckRideScriptForEnterExit = 0x80283810; // type:func rom:0x7E4690 +CheckUsingRideablePartner = 0x80283810; // type:func rom:0x7E4690 TeleportPartnerToPlayer = 0x8028387C; // type:func rom:0x7E46FC SetPlayerPositionFromSaveData = 0x80283908; // type:func rom:0x7E4788 EnterPlayerPostPipe = 0x80283A50; // type:func rom:0x7E48D0 @@ -27130,11 +27128,11 @@ goompa_802BD600 = 0x802BD600; // type:data world_goombario_HadSpeechPrompt = 0x802BDF30; // type:data func_802BE070 = 0x802BE070; // world_bow_IsHiding = 0x802BE0C0; // type:data -D_802BE300 = 0x802BE300; // type:data +world_watt_D_802BE300 = 0x802BE300; // type:data world_parakarry_UsingAbility = 0x802BEBB0; // type:data D_802BEBC0 = 0x802BEBC0; // type:data world_kooper_ShellTossHoldTime = 0x802BEC50; // type:data -OriginalPlayerY = 0x802BFEE0; // type:data +world_sushie_WaterSurfaceY = 0x802BFEE0; // type:data D_802BFEF0 = 0x802BFEF0; // type:data D_802BFEFC = 0x802BFEFC; // type:data D_802BFF30 = 0x802BFF30; // type:data @@ -27318,7 +27316,7 @@ dead_gPlayerStatusPtr = 0x800FFC90; // type:data dead:yes dead_wPartnerHudScripts = 0x80100060; // type:data dead:yes dead_wDisabledPartnerHudScripts = 0x801000A0; // type:data dead:yes dead_80117163 = 0x80117160; // type:data dead:yes -dead_gPartnerActionStatus = 0x80117160; // type:data dead:yes +dead_gPartnerStatus = 0x80117160; // type:data dead:yes dead_gPlayerStatus = 0x80117578; // type:data dead:yes dead_gPlayerData = 0x80117840; // type:data dead:yes dead_gCollisionStatus = 0x80169B10; // type:data dead:yes diff --git a/ver/us/undefined_syms.txt b/ver/us/undefined_syms.txt index 31d1d53fec..11e777c77a 100644 --- a/ver/us/undefined_syms.txt +++ b/ver/us/undefined_syms.txt @@ -243,7 +243,7 @@ dead_create_standard_popup_menu = create_standard_popup_menu + 0x7ECC; dead_gPlayerStatusPtr = gPlayerStatusPtr + 0x8160; dead_wPartnerHudScripts = wPartnerHudScripts + 0x8160; dead_wDisabledPartnerHudScripts = wDisabledPartnerHudScripts + 0x8160; -dead_gPartnerActionStatus = gPartnerActionStatus + 0x85B0; +dead_gPartnerStatus = gPartnerStatus + 0x85B0; dead_gPlayerStatus = gPlayerStatus + 0x85B0; dead_gPlayerData = gPlayerData + 0x85B0; dead_get_entity_by_index = get_entity_by_index + 0x85C8;