diff --git a/config/us/rnc1.us.yaml b/config/us/rnc1.us.yaml index ec70bb28fe..474407b453 100644 --- a/config/us/rnc1.us.yaml +++ b/config/us/rnc1.us.yaml @@ -156,7 +156,7 @@ segments: - [0x196d0, c, assembly/sdk/display/set_gs_crt] - [0x196e0, c, assembly/sdk/system/exit] - [0x196f0, c, assembly/sdk/syscalls/invoke_kernel_syscall_0008] - - [0x19700, c, assembly/sdk/syscalls/invoke_kernel_syscall_000c] + - [0x19700, c, assembly/sdk/system/interrupt2_iop] - [0x19710, c, assembly/sdk/interrupts/add_intc_handler] - [0x19720, c, assembly/sdk/interrupts/remove_intc_handler] - [0x19730, c, assembly/sdk/interrupts/add_dmac_handler] @@ -167,25 +167,25 @@ segments: - [0x19780, c, assembly/sdk/interrupts/enable_dmac] - [0x19790, c, assembly/sdk/interrupts/disable_dmac] - [0x197a0, c, assembly/sdk/interrupts/set_alarm] - - [0x197b0, c, assembly/sdk/syscalls/invoke_kernel_syscall_ffe6] + - [0x197b0, c, assembly/sdk/interrupts/i_enable_intc] - [0x197c0, c, assembly/sdk/syscalls/invoke_kernel_syscall_ff02] - [0x197d0, c, assembly/sdk/threads/create_thread] - [0x197e0, c, assembly/sdk/threads/delete_thread] - [0x197f0, c, assembly/sdk/threads/start_thread] - [0x19800, c, assembly/sdk/threads/terminate_thread] - - [0x19810, c, assembly/sdk/syscalls/invoke_kernel_syscall_ffda] + - [0x19810, c, assembly/sdk/threads/i_terminate_thread] - [0x19820, c, assembly/sdk/threads/change_thread_priority] - - [0x19830, c, assembly/sdk/syscalls/invoke_kernel_syscall_ffd6] + - [0x19830, c, assembly/sdk/threads/i_change_thread_priority] - [0x19840, c, assembly/sdk/threads/rotate_thread_ready_queue] - - [0x19850, c, assembly/sdk/syscalls/invoke_kernel_syscall_ffd2] + - [0x19850, c, assembly/sdk/threads/i_release_wait_thread] - [0x19860, c, assembly/sdk/threads/get_thread_id] - [0x19870, c, assembly/sdk/threads/refer_thread_status] - [0x19880, c, assembly/sdk/threads/sleep_thread] - [0x19890, c, assembly/sdk/threads/wakeup_thread] - [0x198a0, c, assembly/sdk/threads/i_wakeup_thread] - - [0x198b0, c, assembly/sdk/syscalls/invoke_kernel_syscall_ffca] + - [0x198b0, c, assembly/sdk/threads/i_cancel_wakeup_thread] - [0x198c0, c, assembly/sdk/threads/suspend_thread] - - [0x198d0, c, assembly/sdk/syscalls/invoke_kernel_syscall_ffc6] + - [0x198d0, c, assembly/sdk/threads/i_resume_thread] - [0x198e0, c, assembly/sdk/system/end_of_heap] - [0x198f0, c, assembly/sdk/threads/create_semaphore] - [0x19900, c, assembly/sdk/threads/delete_semaphore] @@ -193,25 +193,25 @@ segments: - [0x19920, c, assembly/sdk/threads/i_signal_semaphore] - [0x19930, c, assembly/sdk/threads/wait_semaphore] - [0x19940, c, assembly/sdk/threads/poll_semaphore] - - [0x19950, c, assembly/sdk/syscalls/invoke_kernel_syscall_ffba] + - [0x19950, c, assembly/sdk/threads/i_poll_semaphore] - [0x19960, c, assembly/sdk/system/set_osd_config_param] - [0x19970, c, assembly/sdk/system/get_osd_config_param] - - [0x19980, c, assembly/sdk/syscalls/invoke_kernel_syscall_004e] + - [0x19980, c, assembly/sdk/display/set_gs_h_param] - [0x19990, c, assembly/sdk/syscalls/invoke_kernel_syscall_0052] - [0x199a0, c, assembly/sdk/syscalls/invoke_kernel_syscall_0056] - [0x199b0, c, assembly/sdk/syscalls/invoke_kernel_syscall_ffa6] - - [0x199c0, c, assembly/sdk/syscalls/invoke_kernel_syscall_005d] - - [0x199d0, c, assembly/sdk/syscalls/invoke_kernel_syscall_005f] + - [0x199c0, c, assembly/sdk/interrupts/disable_intc_handler] + - [0x199d0, c, assembly/sdk/interrupts/disable_dmac_handler] - [0x199e0, c, assembly/sdk/memory/cache/enable_cache] - - [0x199f0, c, assembly/sdk/syscalls/invoke_kernel_syscall_0062] + - [0x199f0, c, assembly/sdk/memory/cache/disable_cache] - [0x19a00, c, assembly/sdk/memory/cache/flush_cache] - - [0x19a10, c, assembly/sdk/syscalls/invoke_kernel_syscall_ff99] + - [0x19a10, c, assembly/sdk/system/i_get_cop0] - [0x19a20, c, assembly/sdk/dma/sce_sif_stop_dma] - - [0x19a30, c, assembly/sdk/syscalls/invoke_kernel_syscall_006c] + - [0x19a30, c, assembly/sdk/system/set_cpu_timer_handler] - [0x19a40, c, assembly/sdk/system/get_osd_config_param2] - [0x19a50, c, assembly/sdk/display/gs_get_imr] - [0x19a60, c, assembly/sdk/display/gs_put_imr] - - [0x19a70, c, assembly/sdk/syscalls/invoke_kernel_syscall_0072] + - [0x19a70, c, assembly/sdk/interrupts/set_pgif_handler] - [0x19a80, c, assembly/sdk/interrupts/set_vsync_flag] - [0x19a90, c, assembly/sdk/dma/sce_sif_dma_stat] - [0x19aa0, c, assembly/sdk/dma/sce_sif_set_dma] @@ -220,7 +220,7 @@ segments: - [0x19ad0, c, assembly/sdk/dma/i_sce_sif_set_dchain] - [0x19ae0, c, assembly/sdk/rpc/sce_sif_set_reg] - [0x19af0, c, assembly/sdk/rpc/sce_sif_get_reg] - - [0x19b00, c, assembly/sdk/syscalls/invoke_kernel_syscall_007b] + - [0x19b00, c, assembly/sdk/system/exec_osd] - [0x19b10, c, assembly/sdk/debug/deci2_call] - [0x19b20, c, assembly/sdk/system/get_memory_size] - [0x19b30, c, assembly/sdk/interrupts/init_tlb] @@ -388,7 +388,7 @@ segments: - [0x1e640, c, sdk/kernel/supplement_crt0] - [0x1e688, c, sdk/system/kernel_copy_rdata] - [0x1e6c0, c, sdk/system/find_kernel_address] - - [0x1e700, c, assembly/sdk/syscalls/invoke_kernel_syscall_0083_rfu] + - [0x1e700, c, assembly/sdk/system/find_address] - [0x1e710, textbin, text_gap_0011d790] - [0x1e718, c, sdk/kernel/InitSystemCallTableAddress] - [0x1e814, textbin, text_gap_0011d798_post_sdk_worker] @@ -482,7 +482,7 @@ segments: - [0x22988, c, sdk/graph/sce_gs_get_gparam] - [0x22994, textbin, text_gap_00121a14] - [0x22998, c, sdk/storage/cdvd/checkModelVersion] - - [0x22a38, c, assembly/sdk/syscalls/invoke_kernel_syscall_0080] + - [0x22a38, c, assembly/sdk/display/get_gs_dx_dy_offset] - [0x22a48, c, sdk/graph/sce_gs_set_def_disp_env] - [0x22dbc, textbin, text_gap_00121ac8_post_sdk_worker] - [0x22dc0, c, sdk/graph/sce_gs_put_disp_env] diff --git a/config/us/symbol_addrs.txt b/config/us/symbol_addrs.txt index 36c2c9c7fb..5beefeb9b0 100644 --- a/config/us/symbol_addrs.txt +++ b/config/us/symbol_addrs.txt @@ -60,26 +60,26 @@ CheckStateRange = 0x00112380; ConvertMultibyteCharacter = 0x00115098; InvokeKernelSyscall0000 = 0x118740; InvokeKernelSyscall0008 = 0x118770; -InvokeKernelSyscall000C = 0x118780; -InvokeKernelSyscallFFE6 = 0x118830; +Interrupt2Iop = 0x118780; +_iEnableIntc = 0x118830; InvokeKernelSyscallFF02 = 0x118840; -InvokeKernelSyscallFFDA = 0x118890; -InvokeKernelSyscallFFD6 = 0x1188b0; -InvokeKernelSyscallFFD2 = 0x1188d0; -InvokeKernelSyscallFFCA = 0x118930; -InvokeKernelSyscallFFC6 = 0x118950; -InvokeKernelSyscallFFBA = 0x1189d0; -InvokeKernelSyscall004E = 0x118a00; +iTerminateThread = 0x118890; +iChangeThreadPriority = 0x1188b0; +iReleaseWaitThread = 0x1188d0; +iCancelWakeupThread = 0x118930; +iResumeThread = 0x118950; +iPollSema = 0x1189d0; +SetGsHParam = 0x118a00; InvokeKernelSyscall0052 = 0x118a10; InvokeKernelSyscall0056 = 0x118a20; InvokeKernelSyscallFFA6 = 0x118a30; -InvokeKernelSyscall005D = 0x118a40; -InvokeKernelSyscall005F = 0x118a50; -InvokeKernelSyscall0062 = 0x118a70; -InvokeKernelSyscallFF99 = 0x118a90; -InvokeKernelSyscall006C = 0x118ab0; -InvokeKernelSyscall0072 = 0x118af0; -InvokeKernelSyscall007B = 0x118b80; +DisableIntcHandler = 0x118a40; +DisableDmacHandler = 0x118a50; +DisableCache = 0x118a70; +iGetCop0 = 0x118a90; +SetCPUTimerHandler = 0x118ab0; +SetPgifHandler = 0x118af0; +ExecOSD = 0x118b80; SetGsCrt = 0x00118750; _Exit = 0x00118760; AddIntcHandler = 0x00118790; @@ -143,10 +143,10 @@ GetCoreDataTable = 0x00121A08; RaiseKernelTrap = 0x001F97B0; ClearStageStateFlag = 0x0023B5E0; InvokeKernelSyscall005A_Rfu = 0x0011D060; -InvokeKernelSyscall0083_Rfu = 0x0011D780; +FindAddress = 0x0011D780; InvokeKernelSyscall005A_RfuWorker = 0x0011D8F8; InvokeKernelSyscall005A_RfuTail = 0x0011DAE0; -InvokeKernelSyscall0080 = 0x00121AB8; +_GetGsDxDyOffset = 0x00121AB8; InitializeStateRecord = 0x0012BBE8; CallGlobalStateResource = 0x00116C70; InitializeRpcCommand = 0x0011ACC0; diff --git a/config/us/unit_categories.json b/config/us/unit_categories.json index 23b1d39b75..e1fd1ae7ab 100644 --- a/config/us/unit_categories.json +++ b/config/us/unit_categories.json @@ -37,31 +37,31 @@ "assembly/sdk/interrupts/init_tlb", "assembly/sdk/syscalls/invoke_kernel_syscall_0000", "assembly/sdk/syscalls/invoke_kernel_syscall_0008", - "assembly/sdk/syscalls/invoke_kernel_syscall_000c", - "assembly/sdk/syscalls/invoke_kernel_syscall_004e", + "assembly/sdk/system/interrupt2_iop", + "assembly/sdk/display/set_gs_h_param", "assembly/sdk/syscalls/invoke_kernel_syscall_0052", "assembly/sdk/syscalls/invoke_kernel_syscall_0056", "assembly/sdk/syscalls/invoke_kernel_syscall_005a_rfu", "assembly/sdk/syscalls/invoke_kernel_syscall_005a_rfu_tail", "assembly/sdk/syscalls/invoke_kernel_syscall_005a_rfu_worker", - "assembly/sdk/syscalls/invoke_kernel_syscall_005d", - "assembly/sdk/syscalls/invoke_kernel_syscall_005f", - "assembly/sdk/syscalls/invoke_kernel_syscall_0062", - "assembly/sdk/syscalls/invoke_kernel_syscall_006c", - "assembly/sdk/syscalls/invoke_kernel_syscall_0072", - "assembly/sdk/syscalls/invoke_kernel_syscall_007b", - "assembly/sdk/syscalls/invoke_kernel_syscall_0080", - "assembly/sdk/syscalls/invoke_kernel_syscall_0083_rfu", + "assembly/sdk/interrupts/disable_intc_handler", + "assembly/sdk/interrupts/disable_dmac_handler", + "assembly/sdk/memory/cache/disable_cache", + "assembly/sdk/system/set_cpu_timer_handler", + "assembly/sdk/interrupts/set_pgif_handler", + "assembly/sdk/system/exec_osd", + "assembly/sdk/display/get_gs_dx_dy_offset", + "assembly/sdk/system/find_address", "assembly/sdk/syscalls/invoke_kernel_syscall_ff02", - "assembly/sdk/syscalls/invoke_kernel_syscall_ff99", + "assembly/sdk/system/i_get_cop0", "assembly/sdk/syscalls/invoke_kernel_syscall_ffa6", - "assembly/sdk/syscalls/invoke_kernel_syscall_ffba", - "assembly/sdk/syscalls/invoke_kernel_syscall_ffc6", - "assembly/sdk/syscalls/invoke_kernel_syscall_ffca", - "assembly/sdk/syscalls/invoke_kernel_syscall_ffd2", - "assembly/sdk/syscalls/invoke_kernel_syscall_ffd6", - "assembly/sdk/syscalls/invoke_kernel_syscall_ffda", - "assembly/sdk/syscalls/invoke_kernel_syscall_ffe6", + "assembly/sdk/threads/i_poll_semaphore", + "assembly/sdk/threads/i_resume_thread", + "assembly/sdk/threads/i_cancel_wakeup_thread", + "assembly/sdk/threads/i_release_wait_thread", + "assembly/sdk/threads/i_change_thread_priority", + "assembly/sdk/threads/i_terminate_thread", + "assembly/sdk/interrupts/i_enable_intc", "assembly/sdk/threads/poll_semaphore", "assembly/sdk/threads/refer_thread_status", "assembly/sdk/interrupts/remove_dmac_handler", diff --git a/include/rnc/camera/camera_globals.h b/include/rnc/camera/camera_globals.h index e54bbeae34..fe48eaecb6 100644 --- a/include/rnc/camera/camera_globals.h +++ b/include/rnc/camera/camera_globals.h @@ -35,11 +35,11 @@ struct CameraOrbit { f32 saved_rotation[4]; /* 0x60: quaternion, the same for the blend rotation */ }; /* size 0x70 */ -/* The camera transition at D_001871B0 (PreviewCamera 0x270). kind 0 runs +/* The camera transition at D_001871B0 (GameCamera 0x270). kind 0 runs blend (step_camera_blend); any other kind runs orbit (advance_alternate_camera_transition). */ struct CameraTransition { - s16 mode; /* 0x00: PreviewCamera.transition_mode */ + s16 mode; /* 0x00: GameCamera.transition_mode */ u8 kind; /* 0x02 */ u8 requested_kind; /* 0x03: becomes kind when a transition starts */ u8 pad_04[0xC]; diff --git a/include/rnc/camera/camera_shake.h b/include/rnc/camera/camera_shake.h new file mode 100644 index 0000000000..b8e4e2418e --- /dev/null +++ b/include/rnc/camera/camera_shake.h @@ -0,0 +1,15 @@ +#ifndef LOMBYTE_RNC_CAMERA_CAMERA_SHAKE_H +#define LOMBYTE_RNC_CAMERA_CAMERA_SHAKE_H + +#include "types.h" + +/* One camera shake channel. apply_camera_shake counts frames down and moves + the camera along a view row by amplitude, fading out over frames_max. */ +struct CameraShake { + f32 amplitude; /* 0x0 */ + f32 offset; /* 0x4: this frame's move */ + s32 frames; /* 0x8: frames left */ + s32 frames_max; /* 0xC: the longest count since the shake started */ +}; + +#endif /* LOMBYTE_RNC_CAMERA_CAMERA_SHAKE_H */ diff --git a/include/rnc/globals.h b/include/rnc/globals.h index 5a2379713e..acec5c1ad3 100644 --- a/include/rnc/globals.h +++ b/include/rnc/globals.h @@ -2,6 +2,8 @@ #define LOMBYTE_RNC_GLOBALS_H #include "types.h" +#include "rnc/world/level_id.h" +#include "rnc/ui/menus/save_data/save_card_state.h" /* * Named game globals, one declaration each. The C name is ours; the label @@ -39,8 +41,8 @@ extern f32 frame_time_cube __asm__("D_0015ED74"); /* Bolts the player holds (the HUD prints it, vendors subtract prices). */ extern s32 current_bolt_count __asm__("D_0015ED98"); -/* Pause/freeze state of the current game mode and its flags. */ -extern s32 mode_freeze_state __asm__("D_0015EEB0"); +/* Memory card state (enum CardState) and the flags of the dialog that shows it. */ +extern s32 save_card_state __asm__("D_0015EEB0"); extern s32 mode_freeze_flags __asm__("D_0015EEB4"); /* GS address of the depth buffer (ZBUF_1 takes it >> 13). */ diff --git a/include/rnc/hero/hero_state.h b/include/rnc/hero/hero_state.h index c7cf74327a..619217dcc4 100644 --- a/include/rnc/hero/hero_state.h +++ b/include/rnc/hero/hero_state.h @@ -135,6 +135,29 @@ enum HeroStateId { HERO_STATE_DYING_ZERO_HEALTH = 0x82 }; +/* Values of HeroState.control_mode, named from the states hero_set_state pairs with each one. + * 0x9, 0xA, 0xB, 0x10, 0x13, 0x15, 0x16 and 0x18 stay numbers: what their states share is not clear. */ +enum HeroControlMode { + HERO_MODE_IDLE = 0x0, + HERO_MODE_RUN = 0x1, + HERO_MODE_FALL = 0x2, + HERO_MODE_LEDGE = 0x3, + HERO_MODE_JUMP = 0x4, + HERO_MODE_LAND = 0x5, + HERO_MODE_ATTACK = 0x6, + HERO_MODE_HURT = 0x7, + HERO_MODE_ITEM_RELEASE_WAIT = 0x8, + HERO_MODE_CROUCH = 0xC, + HERO_MODE_GRAPPLE = 0xD, + HERO_MODE_GRAPPLE_SWING = 0xE, + HERO_MODE_GRIND = 0xF, + HERO_MODE_SWIM = 0x11, + HERO_MODE_WATER_SURFACE = 0x12, + HERO_MODE_DYING = 0x14, + HERO_MODE_RESPAWN_WAIT = 0x19, + HERO_MODE_FOLLOW_PATH = 0x1A +}; + enum HeroAnimationEntryMode { HERO_ANIMATION_ENTRY_OVERRIDE_GUARDS = 0x2 }; diff --git a/include/rnc/overlay/shared/camera/level_camera.h b/include/rnc/overlay/shared/camera/level_camera.h index b8b5959ee3..54b3902d71 100644 --- a/include/rnc/overlay/shared/camera/level_camera.h +++ b/include/rnc/overlay/shared/camera/level_camera.h @@ -5,39 +5,40 @@ #include "rnc/math/vector.h" struct Moby; +struct UpdateCam; -/* The level's game camera. Turrets and cannons check targets against its +/* The level's game camera, the level programs' copy of GameCamera (same layout). Turrets and cannons check targets against its position, pitch and yaw. A shot sets the two amount/frames pairs (0.03 for a few frames), a hard landing sets the first one (0.2 for 40 frames). */ typedef struct LevelCamera { - f32 unk0[12]; /* 0x000: a 3x4 basis; shots copy it as their launch rotation */ - u8 pad30[0x110]; - Vec4 pos; /* 0x140 */ - f32 unk150; - f32 pitch; /* 0x154 */ - f32 yaw; /* 0x158 */ - u8 pad15C[0x4]; - f32 shake_amount; /* 0x160 */ - u8 pad164[0x4]; - s32 shake_frames; /* 0x168 */ - u8 pad16C[0x4]; - f32 shake2_amount; /* 0x170 */ - u8 pad174[0x4]; - s32 shake2_frames; /* 0x178 */ - u8 pad17C[0x4]; - struct Moby *unk180; /* 0x180: the camera moby (its pvars hold the follow camera state) */ - char *unk184; /* 0x184 */ - u8 pad188[0x8]; - u8 unk190[0x30]; - f32 unk1C0[4]; /* 0x1C0 */ - u8 unk1D0[0x84]; - s32 unk254; /* 0x254 */ - u8 pad258[0x4]; + f32 unk0[12]; /* 0x000: a 3x4 basis; shots copy it as their launch rotation */ + u8 pad30[0x110]; + Vec4 pos; /* 0x140 */ + f32 unk150; + f32 pitch; /* 0x154 */ + f32 yaw; /* 0x158 */ + u8 pad15C[0x4]; + f32 shake_amount; /* 0x160: the same two channels as GameCamera.shake */ + f32 shake_offset; /* 0x164 */ + s32 shake_frames; /* 0x168 */ + s32 shake_frames_max; /* 0x16C */ + f32 shake2_amount; /* 0x170 */ + f32 shake2_offset; /* 0x174 */ + s32 shake2_frames; /* 0x178 */ + s32 shake2_frames_max; /* 0x17C */ + struct UpdateCam *current_camera; /* 0x180: the record the view follows */ + struct UpdateCam *previous_camera; /* 0x184 */ + u8 pad188[0x8]; + u8 unk190[0x30]; + f32 unk1C0[4]; /* 0x1C0 */ + u8 unk1D0[0x84]; + s32 unk254; /* 0x254 */ + u8 pad258[0x4]; struct Moby * focus_moby; /* 0x25C: a moby that takes the camera's attention (blarg helicopter); 0: none */ s32 focus_time; /* 0x260: reset to 0 when focus_moby is set */ u8 pad264[0xc]; - s16 unk270; /* 0x270 */ + s16 transition_mode; /* 0x270: GameCamera.transition_mode */ u8 pad272[0x1]; u8 unk273; /* 0x273 */ u8 pad274[0x14]; @@ -47,11 +48,11 @@ typedef struct LevelCamera { u8 pad298[0x5c]; s32 unk2F4; u8 pad2F8[0x58]; - f32 unk350[12]; /* 0x350: basis the hero's input direction is turned by */ + f32 rows[12]; /* 0x350: forward, right and up; the hero's input direction is turned by them */ u8 pad380[0x10]; void (*unk390)(void); /* 0x390: called each frame by the follow camera when set */ - s32 unk394; - s32 unk398; + s32 underwater; /* 0x394 */ + s32 frame_count; /* 0x398 */ u8 pad39C[0x4]; } LevelCamera; diff --git a/include/rnc/ui/menus/menu_globals.h b/include/rnc/ui/menus/menu_globals.h index 0d4895a1cd..8e202db3d3 100644 --- a/include/rnc/ui/menus/menu_globals.h +++ b/include/rnc/ui/menus/menu_globals.h @@ -3,6 +3,7 @@ #include "types.h" #include "rnc/math/vector.h" +#include "rnc/camera/camera_shake.h" extern unsigned char menu_item_enabled_0 __asm__("D_0013D394") __attribute__((section(".data"))); extern unsigned char menu_item_enabled_9 __asm__("D_0013D39D") __attribute__((section(".data"))); @@ -41,14 +42,14 @@ extern MenuItemInfo menu_item_info[] __asm__("D_001863D0"); initialize_level_render_state clears all 0x3A0 bytes. */ struct UpdateCam; -struct PreviewCamera { - f32 view_matrices[0x50]; /* 0x000 */ - Vec4 position; /* 0x140 */ - Vec4 rotation; /* 0x150: basis angles while the camera rows are not published */ - u8 pad160[0x180 - 0x160]; - struct UpdateCam *current_camera; /* 0x180: the record the view follows */ - struct UpdateCam *previous_camera; /* 0x184: start_camera_blend's source */ - u8 pad188[0x258 - 0x188]; +struct GameCamera { + f32 view_matrices[0x50]; /* 0x000 */ + Vec4 position; /* 0x140 */ + Vec4 rotation; /* 0x150: basis angles while the camera rows are not published */ + struct CameraShake shake[2]; /* 0x160: apply_camera_shake, one per view row */ + struct UpdateCam *current_camera; /* 0x180: the record the view follows */ + struct UpdateCam *previous_camera; /* 0x184: start_camera_blend's source */ + u8 pad188[0x258 - 0x188]; f32 timed_control_step; /* 0x258: advance_timed_camera_control subtracts it from sequence */ u8 pad25C[0x270 - 0x25C]; s16 transition_mode; /* 0x270: cam_trans_state's mode; 1/2 start a blend, 3 blends */ @@ -62,7 +63,8 @@ struct PreviewCamera { u8 pad39C[0x4]; }; /* size 0x3A0 */ -extern struct PreviewCamera preview_camera __asm__("D_00186F40"); +extern struct GameCamera game_camera __asm__("D_00186F40"); + /* Level object mobys, indexed by map icon id (copy_level_object_positions, update_map_icons). */ struct Moby; extern struct Moby *menu_action_messages[] __asm__("D_00199478"); diff --git a/include/rnc/ui/menus/save_data/save_card_state.h b/include/rnc/ui/menus/save_data/save_card_state.h index 8c555e1f52..d35ddbbb39 100644 --- a/include/rnc/ui/menus/save_data/save_card_state.h +++ b/include/rnc/ui/menus/save_data/save_card_state.h @@ -3,4 +3,34 @@ #include "types.h" +/* Values of save_card_state. The names are the game's own: the levels keep a table of + * these names right after the handler table that run_state_handler indexes. */ +enum CardState { + CS_INIT = 0, + CS_GOOD_SAVE = 1, + CS_WARNING = 2, + CS_NOCARD = 3, + CS_WAIT_FOR_CARD = 4, + CS_UNFORMATTED = 5, + CS_PROMPT_FORMAT = 6, + CS_FORMAT_PENDING = 7, + CS_FORMATTING = 8, + CS_FORMATTED = 9, + CS_CHECK_SAVE = 10, + CS_CHECKING_SAVE = 11, + CS_NOSAVE = 12, + CS_PROMPT_CREATE_SAVE = 13, + CS_CREATE_SAVE_PENDING = 14, + CS_CREATING_SAVE = 15, + CS_NEWCARD = 16, + CS_FORMAT_FAILED = 17, + CS_CREATE_FAILED = 18, + CS_NO_ROOM = 19, + CS_LOAD_FAILED = 20, + CS_SAVE_FAILED = 21, + CS_SAVING = 22, + CS_PROMPT_BEGIN_UNFORMATTED = 23, + CS_PROMPT_BEGIN_NOSAVE = 24 +}; + #endif /* LOMBYTE_RNC_UI_MENUS_SAVE_DATA_SAVE_CARD_STATE_H */ diff --git a/include/rnc/world/level_id.h b/include/rnc/world/level_id.h new file mode 100644 index 0000000000..81efacfd54 --- /dev/null +++ b/include/rnc/world/level_id.h @@ -0,0 +1,29 @@ +#ifndef LOMBYTE_RNC_WORLD_LEVEL_ID_H +#define LOMBYTE_RNC_WORLD_LEVEL_ID_H + +/* Values of current_level_index, in the order of the level table + * (config/us/levels/levels.json). Folders src/overlays/lNN use the same numbers. */ +enum LevelId { + LEVEL_VELDIN1 = 0x0, + LEVEL_NOVALIS = 0x1, + LEVEL_ARIDIA = 0x2, + LEVEL_KERWAN = 0x3, + LEVEL_EUDORA = 0x4, + LEVEL_RILGAR = 0x5, + LEVEL_NEBULA_G34 = 0x6, + LEVEL_UMBRIS = 0x7, + LEVEL_BATALIA = 0x8, + LEVEL_GASPAR = 0x9, + LEVEL_ORXON = 0xA, + LEVEL_POKITARU = 0xB, + LEVEL_HOVEN = 0xC, + LEVEL_OLTANIS_ORBIT = 0xD, + LEVEL_OLTANIS = 0xE, + LEVEL_QUARTU = 0xF, + LEVEL_KALEBO3 = 0x10, + LEVEL_VELDIN_ORBIT = 0x11, + LEVEL_VELDIN2 = 0x12, + LEVEL_COUNT = 0x13 +}; + +#endif /* LOMBYTE_RNC_WORLD_LEVEL_ID_H */ diff --git a/src/assembly/sdk/display/get_gs_dx_dy_offset.c b/src/assembly/sdk/display/get_gs_dx_dy_offset.c new file mode 100644 index 0000000000..9a6d0b05de --- /dev/null +++ b/src/assembly/sdk/display/get_gs_dx_dy_offset.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/display/get_gs_dx_dy_offset/" + "_GetGsDxDyOffset.s", _GetGsDxDyOffset); diff --git a/src/assembly/sdk/display/set_gs_h_param.c b/src/assembly/sdk/display/set_gs_h_param.c new file mode 100644 index 0000000000..22447e9158 --- /dev/null +++ b/src/assembly/sdk/display/set_gs_h_param.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/display/set_gs_h_param/" + "SetGsHParam.s", SetGsHParam); diff --git a/src/assembly/sdk/interrupts/disable_dmac_handler.c b/src/assembly/sdk/interrupts/disable_dmac_handler.c new file mode 100644 index 0000000000..2aa0836d65 --- /dev/null +++ b/src/assembly/sdk/interrupts/disable_dmac_handler.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/interrupts/disable_dmac_handler/" + "DisableDmacHandler.s", DisableDmacHandler); diff --git a/src/assembly/sdk/interrupts/disable_intc_handler.c b/src/assembly/sdk/interrupts/disable_intc_handler.c new file mode 100644 index 0000000000..9ceca2f203 --- /dev/null +++ b/src/assembly/sdk/interrupts/disable_intc_handler.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/interrupts/disable_intc_handler/" + "DisableIntcHandler.s", DisableIntcHandler); diff --git a/src/assembly/sdk/interrupts/i_enable_intc.c b/src/assembly/sdk/interrupts/i_enable_intc.c new file mode 100644 index 0000000000..c6cd3206f0 --- /dev/null +++ b/src/assembly/sdk/interrupts/i_enable_intc.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/interrupts/i_enable_intc/" + "_iEnableIntc.s", _iEnableIntc); diff --git a/src/assembly/sdk/interrupts/set_pgif_handler.c b/src/assembly/sdk/interrupts/set_pgif_handler.c new file mode 100644 index 0000000000..7140e43769 --- /dev/null +++ b/src/assembly/sdk/interrupts/set_pgif_handler.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/interrupts/set_pgif_handler/" + "SetPgifHandler.s", SetPgifHandler); diff --git a/src/assembly/sdk/memory/cache/disable_cache.c b/src/assembly/sdk/memory/cache/disable_cache.c new file mode 100644 index 0000000000..5ee9993a10 --- /dev/null +++ b/src/assembly/sdk/memory/cache/disable_cache.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/memory/cache/disable_cache/" + "DisableCache.s", DisableCache); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_000c.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_000c.c deleted file mode 100644 index 81a58eaf55..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_000c.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_000c/" - "InvokeKernelSyscall000C.s", InvokeKernelSyscall000C); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_004e.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_004e.c deleted file mode 100644 index e80f938318..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_004e.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_004e/" - "InvokeKernelSyscall004E.s", InvokeKernelSyscall004E); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_005d.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_005d.c deleted file mode 100644 index c81cf80077..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_005d.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_005d/" - "InvokeKernelSyscall005D.s", InvokeKernelSyscall005D); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_005f.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_005f.c deleted file mode 100644 index 78d8f23364..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_005f.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_005f/" - "InvokeKernelSyscall005F.s", InvokeKernelSyscall005F); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_0062.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_0062.c deleted file mode 100644 index 619a880db4..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_0062.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_0062/" - "InvokeKernelSyscall0062.s", InvokeKernelSyscall0062); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_006c.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_006c.c deleted file mode 100644 index bafc5ac997..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_006c.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_006c/" - "InvokeKernelSyscall006C.s", InvokeKernelSyscall006C); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_0072.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_0072.c deleted file mode 100644 index 91c4f42cf7..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_0072.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_0072/" - "InvokeKernelSyscall0072.s", InvokeKernelSyscall0072); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_007b.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_007b.c deleted file mode 100644 index 7125a8d56b..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_007b.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_007b/" - "InvokeKernelSyscall007B.s", InvokeKernelSyscall007B); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_0080.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_0080.c deleted file mode 100644 index d3e85d88dd..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_0080.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_0080/" - "InvokeKernelSyscall0080.s", InvokeKernelSyscall0080); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_0083_rfu.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_0083_rfu.c deleted file mode 100644 index b36ebd0ff5..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_0083_rfu.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_0083_rfu/" - "InvokeKernelSyscall0083_Rfu.s", InvokeKernelSyscall0083_Rfu); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_ff99.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_ff99.c deleted file mode 100644 index 45fa03ede3..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_ff99.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_ff99/" - "InvokeKernelSyscallFF99.s", InvokeKernelSyscallFF99); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffba.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffba.c deleted file mode 100644 index f806e85a0e..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffba.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_ffba/" - "InvokeKernelSyscallFFBA.s", InvokeKernelSyscallFFBA); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffc6.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffc6.c deleted file mode 100644 index 7f32a71fb0..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffc6.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_ffc6/" - "InvokeKernelSyscallFFC6.s", InvokeKernelSyscallFFC6); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffca.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffca.c deleted file mode 100644 index e6de4cbfb4..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffca.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_ffca/" - "InvokeKernelSyscallFFCA.s", InvokeKernelSyscallFFCA); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffd2.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffd2.c deleted file mode 100644 index eedc4b1171..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffd2.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_ffd2/" - "InvokeKernelSyscallFFD2.s", InvokeKernelSyscallFFD2); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffd6.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffd6.c deleted file mode 100644 index e865b73552..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffd6.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_ffd6/" - "InvokeKernelSyscallFFD6.s", InvokeKernelSyscallFFD6); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffda.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffda.c deleted file mode 100644 index 103989f14d..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffda.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_ffda/" - "InvokeKernelSyscallFFDA.s", InvokeKernelSyscallFFDA); diff --git a/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffe6.c b/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffe6.c deleted file mode 100644 index d3374c9f58..0000000000 --- a/src/assembly/sdk/syscalls/invoke_kernel_syscall_ffe6.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "asm.h" - -INCLUDE_ASM("config/us/expected/asm/assembly/sdk/syscalls/invoke_kernel_syscall_ffe6/" - "InvokeKernelSyscallFFE6.s", InvokeKernelSyscallFFE6); diff --git a/src/assembly/sdk/system/exec_osd.c b/src/assembly/sdk/system/exec_osd.c new file mode 100644 index 0000000000..9eeff6a139 --- /dev/null +++ b/src/assembly/sdk/system/exec_osd.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/system/exec_osd/" + "ExecOSD.s", ExecOSD); diff --git a/src/assembly/sdk/system/find_address.c b/src/assembly/sdk/system/find_address.c new file mode 100644 index 0000000000..9a976e583f --- /dev/null +++ b/src/assembly/sdk/system/find_address.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/system/find_address/" + "FindAddress.s", FindAddress); diff --git a/src/assembly/sdk/system/i_get_cop0.c b/src/assembly/sdk/system/i_get_cop0.c new file mode 100644 index 0000000000..87f688fde1 --- /dev/null +++ b/src/assembly/sdk/system/i_get_cop0.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/system/i_get_cop0/" + "iGetCop0.s", iGetCop0); diff --git a/src/assembly/sdk/system/interrupt2_iop.c b/src/assembly/sdk/system/interrupt2_iop.c new file mode 100644 index 0000000000..09b0645825 --- /dev/null +++ b/src/assembly/sdk/system/interrupt2_iop.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/system/interrupt2_iop/" + "Interrupt2Iop.s", Interrupt2Iop); diff --git a/src/assembly/sdk/system/set_cpu_timer_handler.c b/src/assembly/sdk/system/set_cpu_timer_handler.c new file mode 100644 index 0000000000..110b1c75ed --- /dev/null +++ b/src/assembly/sdk/system/set_cpu_timer_handler.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/system/set_cpu_timer_handler/" + "SetCPUTimerHandler.s", SetCPUTimerHandler); diff --git a/src/assembly/sdk/threads/i_cancel_wakeup_thread.c b/src/assembly/sdk/threads/i_cancel_wakeup_thread.c new file mode 100644 index 0000000000..310d4cf59f --- /dev/null +++ b/src/assembly/sdk/threads/i_cancel_wakeup_thread.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/threads/i_cancel_wakeup_thread/" + "iCancelWakeupThread.s", iCancelWakeupThread); diff --git a/src/assembly/sdk/threads/i_change_thread_priority.c b/src/assembly/sdk/threads/i_change_thread_priority.c new file mode 100644 index 0000000000..a8ab01de2b --- /dev/null +++ b/src/assembly/sdk/threads/i_change_thread_priority.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/threads/i_change_thread_priority/" + "iChangeThreadPriority.s", iChangeThreadPriority); diff --git a/src/assembly/sdk/threads/i_poll_semaphore.c b/src/assembly/sdk/threads/i_poll_semaphore.c new file mode 100644 index 0000000000..9124d785f8 --- /dev/null +++ b/src/assembly/sdk/threads/i_poll_semaphore.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/threads/i_poll_semaphore/" + "iPollSema.s", iPollSema); diff --git a/src/assembly/sdk/threads/i_release_wait_thread.c b/src/assembly/sdk/threads/i_release_wait_thread.c new file mode 100644 index 0000000000..6d068d5e26 --- /dev/null +++ b/src/assembly/sdk/threads/i_release_wait_thread.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/threads/i_release_wait_thread/" + "iReleaseWaitThread.s", iReleaseWaitThread); diff --git a/src/assembly/sdk/threads/i_resume_thread.c b/src/assembly/sdk/threads/i_resume_thread.c new file mode 100644 index 0000000000..71f1a63ae4 --- /dev/null +++ b/src/assembly/sdk/threads/i_resume_thread.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/threads/i_resume_thread/" + "iResumeThread.s", iResumeThread); diff --git a/src/assembly/sdk/threads/i_terminate_thread.c b/src/assembly/sdk/threads/i_terminate_thread.c new file mode 100644 index 0000000000..caa90b1a9c --- /dev/null +++ b/src/assembly/sdk/threads/i_terminate_thread.c @@ -0,0 +1,4 @@ +#include "asm.h" + +INCLUDE_ASM("config/us/expected/asm/assembly/sdk/threads/i_terminate_thread/" + "iTerminateThread.s", iTerminateThread); diff --git a/src/audio/voices/pause_all_sounds.c b/src/audio/voices/pause_all_sounds.c index a8fbf4c650..34e701a7d3 100644 --- a/src/audio/voices/pause_all_sounds.c +++ b/src/audio/voices/pause_all_sounds.c @@ -53,11 +53,11 @@ void pause_all_sounds(s32 mode) { } { struct MenuSystem *g = &menu_system; - g->unk134 = *(volatile s32 *)¤t_level_index == 0xD || D_0014161B != 0; + g->unk134 = *(volatile s32 *)¤t_level_index == LEVEL_OLTANIS_ORBIT || D_0014161B != 0; } { struct MenuSystem *g = &menu_system; - g->unk138 = current_level_index == 0 || current_level_index == 0xE; + g->unk138 = current_level_index == LEVEL_VELDIN1 || current_level_index == LEVEL_OLTANIS; } { struct MenuSystem *g = &menu_system; diff --git a/src/camera/advance_timed_camera_control.c b/src/camera/advance_timed_camera_control.c index fec85320e1..e4d6bf69a8 100644 --- a/src/camera/advance_timed_camera_control.c +++ b/src/camera/advance_timed_camera_control.c @@ -7,14 +7,14 @@ void advance_timed_camera_control(void) __asm__("FUN_001eda60"); void advance_timed_camera_control(void) { - float decrement = preview_camera.timed_control_step; + float decrement = game_camera.timed_control_step; float remaining; if (decrement != 0.0f) { remaining = sequence - decrement; sequence = remaining; if (remaining <= 0.0f) { - preview_camera.timed_control_step = 0.0f; + game_camera.timed_control_step = 0.0f; *(volatile float *)&sequence = 0.0f; } } diff --git a/src/camera/apply_camera_shake.c b/src/camera/apply_camera_shake.c index 766de120ee..10d1d4159b 100644 --- a/src/camera/apply_camera_shake.c +++ b/src/camera/apply_camera_shake.c @@ -2,16 +2,10 @@ #include "rnc/camera/update_cam.h" #include "rnc/camera/camera_globals.h" +#include "rnc/camera/camera_shake.h" #include "rnc/math/fast_math.h" #include "rnc/math/asm_helpers.h" -struct CameraShake { - f32 unk0; - f32 unk4; - s32 unk8; - s32 unkC; -}; - extern struct UpdateCam *cur_cam[] __asm__("D_001870C0"); extern u8 D_001872B0[]; @@ -30,23 +24,23 @@ void apply_camera_shake(struct CameraShake *shake, s32 axis_index) { s32 remaining_frames; if (cur_cam[0] != 0 && cur_cam[0]->unk86 == 6) { - shake->unk8 = 0; - shake->unkC = 0; + shake->frames = 0; + shake->frames_max = 0; } else { - remaining_frames = shake->unk8; + remaining_frames = shake->frames; if (remaining_frames != 0) { - if (shake->unkC < remaining_frames) { - shake->unkC = remaining_frames; + if (shake->frames_max < remaining_frames) { + shake->frames_max = remaining_frames; } - fast_dec_timer(&shake->unk8); - remaining_frames_float = convert_integer_to_float(shake->unk8); - total_frames_float = convert_integer_to_float(shake->unkC); + fast_dec_timer(&shake->frames); + remaining_frames_float = convert_integer_to_float(shake->frames); + total_frames_float = convert_integer_to_float(shake->frames_max); remaining_frame_ratio = remaining_frames_float / total_frames_float; oscillation_cosine = - fast_cos(fast_normalize_angle(2.0f * convert_integer_to_float(shake->unk8))); - applied_shake_offset = - shake->unk0 * oscillation_cosine * remaining_frame_ratio * remaining_frame_ratio; - shake->unk4 = applied_shake_offset; + fast_cos(fast_normalize_angle(2.0f * convert_integer_to_float(shake->frames))); + applied_shake_offset = shake->amplitude * oscillation_cosine * remaining_frame_ratio * + remaining_frame_ratio; + shake->offset = applied_shake_offset; if (axis_index == 0) { fast_vec_normalize(shake_offset, D_001872B0, applied_shake_offset); } else { @@ -54,7 +48,7 @@ void apply_camera_shake(struct CameraShake *shake, s32 axis_index) { } fast_vec_add(camera_position, camera_position, shake_offset); } else { - shake->unkC = 0; + shake->frames_max = 0; } } } diff --git a/src/camera/refresh_camera_control_flags.c b/src/camera/refresh_camera_control_flags.c index 6b6c05c812..8c6dc984b6 100644 --- a/src/camera/refresh_camera_control_flags.c +++ b/src/camera/refresh_camera_control_flags.c @@ -30,7 +30,8 @@ void refresh_camera_control_flags(void) { if ((u32)(hero.state.control_mode - 0x11) < 2U || hero.state.current == 0x73) { cam_coll_flag = 0x34; } - if (hero.state.control_mode != 0x11 && hero.water_surface_z < *(f32 *)(camera_position + 8)) { + if (hero.state.control_mode != HERO_MODE_SWIM && + hero.water_surface_z < *(f32 *)(camera_position + 8)) { cam_coll_flag = 0x14; } cam_coll_flag_prev = cam_coll_flag; diff --git a/src/camera/start_camera_blend.c b/src/camera/start_camera_blend.c index 5191c43842..3409edc045 100644 --- a/src/camera/start_camera_blend.c +++ b/src/camera/start_camera_blend.c @@ -48,7 +48,7 @@ void start_camera_blend(struct UpdateCam *source) { fast_vec_normalize( orbit_yaw_side_direction, &orbit_reference_hero->moby->rot_row1, 1.0f); fast_vec_normalize(orbit_axis, &orbit_reference_hero->moby->rot_row2, 1.0f); - /* PreviewCamera.current_camera, reached from this base. */ + /* GameCamera.current_camera, reached from this base. */ compute_camera_angles(transition->orbit.angles, &source->pos, *(char **)((char *)transition - 0xF0) + 0x30, diff --git a/src/camera/switch_active_camera_record.c b/src/camera/switch_active_camera_record.c index c2a944f5bc..868c3e28bd 100644 --- a/src/camera/switch_active_camera_record.c +++ b/src/camera/switch_active_camera_record.c @@ -39,7 +39,7 @@ struct CameraTransitionState { s32 snapshot_pending; }; -extern struct CameraTransitionState preview_camera __asm__("D_00186F40"); +extern struct CameraTransitionState game_camera __asm__("D_00186F40"); extern void camera_run_setup_to_new_cam(struct UpdateCam *next_camera) __asm__("func_001EBEC8"); extern void fast_mem_copy(void *dst, void *src, s32 size) __asm__("func_001F98D0"); @@ -81,7 +81,7 @@ void switch_active_camera_record(struct UpdateCam *next_camera) { s32 previous_transition_state; descriptor = D_0015EF90[next_camera->descriptor_index].descriptor; - previous_camera = preview_camera.current; + previous_camera = game_camera.current; previous_transition_state = previous_camera->transition_state; if (descriptor != 0) { descriptor_kind = descriptor->descriptor_kind; @@ -93,27 +93,27 @@ void switch_active_camera_record(struct UpdateCam *next_camera) { descriptor_kind == CAMERA_DESCRIPTOR_FRAME_COUNT_TRANSITION) { if (descriptor_kind == CAMERA_DESCRIPTOR_RATE_TRANSITION) { mode_one_duration = next_camera->transition_duration; - preview_camera.transition_mode = CAMERA_TRANSITION_RATE_BASED; + game_camera.transition_mode = CAMERA_TRANSITION_RATE_BASED; if (mode_one_duration > 0.0f) { - preview_camera.configured_position_rate = mode_one_duration; - preview_camera.configured_rotation_rate = mode_one_duration; + game_camera.configured_position_rate = mode_one_duration; + game_camera.configured_rotation_rate = mode_one_duration; } else { - preview_camera.configured_position_rate = 0.018f; - preview_camera.configured_rotation_rate = 0.018f; + game_camera.configured_position_rate = 0.018f; + game_camera.configured_rotation_rate = 0.018f; } } else if (descriptor_kind == CAMERA_DESCRIPTOR_FRAME_COUNT_TRANSITION) { transition_duration = next_camera->transition_duration; - preview_camera.transition_mode = CAMERA_TRANSITION_FRAME_COUNT_BASED; + game_camera.transition_mode = CAMERA_TRANSITION_FRAME_COUNT_BASED; if (transition_duration > 0.0f) { - preview_camera.configured_frames = truncate_float_to_s32(transition_duration); + game_camera.configured_frames = truncate_float_to_s32(transition_duration); } else { - preview_camera.configured_frames = 40; + game_camera.configured_frames = 40; } } - if (preview_camera.transition_phase == 0) { - preview_camera.transition_phase = 1; + if (game_camera.transition_phase == 0) { + game_camera.transition_phase = 1; } else { - preview_camera.transition_phase = 2; + game_camera.transition_phase = 2; } } else if (previous_transition_state == CAMERA_TRANSITION_STATE_INHERIT_TRANSFORM || previous_transition_state == @@ -129,22 +129,22 @@ void switch_active_camera_record(struct UpdateCam *next_camera) { CAMERA_TRANSITION_STATE_INHERIT_TRANSFORM_WITH_RATE_TRANSITION || descriptor_kind == CAMERA_DESCRIPTOR_INHERIT_TRANSFORM_WITH_RATE_TRANSITION) { handoff_duration = next_camera->transition_duration; - preview_camera.transition_mode = CAMERA_TRANSITION_RATE_BASED; + game_camera.transition_mode = CAMERA_TRANSITION_RATE_BASED; if (handoff_duration > 0.0f) { - preview_camera.configured_position_rate = handoff_duration; - preview_camera.configured_rotation_rate = handoff_duration; + game_camera.configured_position_rate = handoff_duration; + game_camera.configured_rotation_rate = handoff_duration; } else { - preview_camera.configured_position_rate = 0.018f; - preview_camera.configured_rotation_rate = 0.018f; - if (current_level_index == 1) { - preview_camera.configured_position_rate = 0.01f; - preview_camera.configured_rotation_rate = 0.01f; + game_camera.configured_position_rate = 0.018f; + game_camera.configured_rotation_rate = 0.018f; + if (current_level_index == LEVEL_NOVALIS) { + game_camera.configured_position_rate = 0.01f; + game_camera.configured_rotation_rate = 0.01f; } } - if (preview_camera.transition_phase == 0) { - preview_camera.transition_phase = 1; + if (game_camera.transition_phase == 0) { + game_camera.transition_phase = 1; } else { - preview_camera.transition_phase = 2; + game_camera.transition_phase = 2; } } } else { @@ -155,17 +155,17 @@ void switch_active_camera_record(struct UpdateCam *next_camera) { previous_camera->transition_state = CAMERA_TRANSITION_STATE_CLEARED; previous_camera->handoff_state = CAMERA_HANDOFF_NONE; previous_camera->activation_blocked = 0; - preview_camera.previous = previous_camera; + game_camera.previous = previous_camera; fast_mem_copy(&camera_saved_states[1], &camera_saved_states[0], 0x280); - preview_camera.previous->saved_state = &camera_saved_states[1]; - preview_camera.current = next_camera; + game_camera.previous->saved_state = &camera_saved_states[1]; + game_camera.current = next_camera; next_camera->saved_state = &camera_saved_states[0]; - preview_camera.snapshot_pending = 0; + game_camera.snapshot_pending = 0; camera_run_setup_to_new_cam(next_camera); backup_current_cam(); /* The callbacks run before this flag is read; previous_position is updated either way. */ if (camera_position_publication_suppressed[0] == 0) { - qcopy(&preview_camera.published_position, &next_camera->pos); + qcopy(&game_camera.published_position, &next_camera->pos); } previous_position = &next_camera->prev_pos.x; previous_position[0] = next_camera->pos.x; diff --git a/src/camera/transition_update_movie_camera.c b/src/camera/transition_update_movie_camera.c index 68e33c8253..5fabf50890 100644 --- a/src/camera/transition_update_movie_camera.c +++ b/src/camera/transition_update_movie_camera.c @@ -18,11 +18,11 @@ unsigned char transition_update_movie_camera(void) { char *camera_keyframe_state = render_sequence; char *key = *(char **)(camera_keyframe_state + 0x54) + *(int *)(camera_keyframe_state + 0x38) * 32; - unsigned char flag = key[0xC]; - float *keyframe_rotation_angles = (float *)(key + 0x10); - char *active_camera_position; - struct PreviewCamera *camera_basis_write_base; - float camera_rotation_matrix[16]; + unsigned char flag = key[0xC]; + float *keyframe_rotation_angles = (float *)(key + 0x10); + char *active_camera_position; + struct GameCamera *camera_basis_write_base; + float camera_rotation_matrix[16]; view_tan_half_fov = 0.63f; update_view_context(); @@ -32,7 +32,7 @@ unsigned char transition_update_movie_camera(void) { SceVu0RotMatrixX(camera_rotation_matrix, camera_rotation_matrix, *(float *)(key + 0x10)); SceVu0RotMatrixY(camera_rotation_matrix, camera_rotation_matrix, keyframe_rotation_angles[1]); sceVu0RotMatrixZ(camera_rotation_matrix, camera_rotation_matrix, keyframe_rotation_angles[2]); - camera_basis_write_base = (struct PreviewCamera *)(active_camera_position - 0x140); + camera_basis_write_base = (struct GameCamera *)(active_camera_position - 0x140); camera_basis_write_base->forward.f[0] = -camera_rotation_matrix[8]; camera_basis_write_base->right.f[0] = -camera_rotation_matrix[0]; camera_basis_write_base->up.f[0] = camera_rotation_matrix[4]; diff --git a/src/camera/update_camera.c b/src/camera/update_camera.c index dd2be1a649..43b9f4980c 100644 --- a/src/camera/update_camera.c +++ b/src/camera/update_camera.c @@ -37,10 +37,10 @@ void update_camera(void) { CAMERA_TRANSITION_KIND_PRIMARY = 0, CAMERA_TRANSITION_PHASE_BLENDING = 3 }; - struct PreviewCamera *camera; - struct UpdateCam *target; - char *camera_shake_base; - float rotation_matrix[16]; + struct GameCamera *camera; + struct UpdateCam *target; + char *camera_shake_base; + float rotation_matrix[16]; if (game_mode_macro == 5) { if (text_screen_active[0] != 0) { @@ -49,7 +49,7 @@ void update_camera(void) { cam_trans_state.mode = CAMERA_TRANSITION_PHASE_IDLE; cam_trans_state.kind = CAMERA_TRANSITION_KIND_PRIMARY; } - camera = &preview_camera; + camera = &game_camera; camera->frame_count++; advance_timed_camera_control(); refresh_camera_control_flags(); diff --git a/src/camera/update_camera_underwater_flag.c b/src/camera/update_camera_underwater_flag.c index 34a45591eb..067da8c826 100644 --- a/src/camera/update_camera_underwater_flag.c +++ b/src/camera/update_camera_underwater_flag.c @@ -14,10 +14,10 @@ void update_camera_underwater_flag(void) __asm__("FUN_001ed7f0"); extern s32 game_mode_macro __asm__("D_0015F604") MACRO_ADDR; void update_camera_underwater_flag(void) { - struct PreviewCamera *camera = &preview_camera; - float probe_start[4]; - float probe_end[4]; - int i; + struct GameCamera *camera = &game_camera; + float probe_start[4]; + float probe_end[4]; + int i; if (camera->current_camera->unk86 == 6 || game_mode_macro != 0) { camera->underwater = 0; @@ -32,7 +32,7 @@ void update_camera_underwater_flag(void) { if (collision_hit_material() == 0) { float submersion_height_threshold = resolve_camera_surface_height(D_00194120, 0) + 0.04f; - struct PreviewCamera *focus_camera = &preview_camera; + struct GameCamera *focus_camera = &game_camera; if (focus_camera->position.f[2] < submersion_height_threshold) { focus_camera->underwater = 1; diff --git a/src/game/initialize_level_runtime.c b/src/game/initialize_level_runtime.c index 9621560897..ede7f5202d 100644 --- a/src/game/initialize_level_runtime.c +++ b/src/game/initialize_level_runtime.c @@ -278,7 +278,8 @@ void initialize_level_runtime(void) { level_render_state.history_index = 0; level_render_state.history_count = 0; qcopy(&D_001604F0, &D_001604E0); - if (current_level_index == 0 || (current_level_index == 1 && level_available[3] == 0)) { + if (current_level_index == LEVEL_VELDIN1 || + (current_level_index == LEVEL_NOVALIS && level_available[3] == 0)) { level_render_state.scene_mode = LEVEL_SCENE_MODE_EARLY_PROGRESSION; level_render_state.scene_state = 2; } diff --git a/src/game/process_global_state_flags.c b/src/game/process_global_state_flags.c index 1715430321..1657500e74 100644 --- a/src/game/process_global_state_flags.c +++ b/src/game/process_global_state_flags.c @@ -27,7 +27,7 @@ s32 process_global_state_flags(void) { s32 fade_duration_frames; if ((controller_state.pressed & PAD_CIRCLE) != 0) { - if (mode_freeze_state == 1 || mode_freeze_state == 0x10) { + if (save_card_state == CS_GOOD_SAVE || save_card_state == CS_NEWCARD) { menu_system.next = (struct MenuPage *)circle_target_menu_page; } else { load_level_zero_preserving_progress(-1); diff --git a/src/game/update_level_gameplay_frame.c b/src/game/update_level_gameplay_frame.c index 3136f23694..5ccef1d4d1 100644 --- a/src/game/update_level_gameplay_frame.c +++ b/src/game/update_level_gameplay_frame.c @@ -200,8 +200,8 @@ void update_level_gameplay_frame(void) { if (sequence_macro < 0.0f) { sequence_macro = 0.0f; } - if (render_sequence.time == 1 && current_level_index != 0 && - (current_level_index != 1 || level_available[3] != 0)) { + if (render_sequence.time == 1 && current_level_index != LEVEL_VELDIN1 && + (current_level_index != LEVEL_NOVALIS || level_available[3] != 0)) { snd_hold_command_batches(); snd_play_sound_vol_pan_pmpb(sound_bank_handle, level_render_state.mode, @@ -224,8 +224,8 @@ void update_level_gameplay_frame(void) { mark_moby_for_removal(expired_object); } } - if (current_level_index != 0 && (current_level_index != 1 || level_available[3] != 0) && - D_0015EE48 < 3) { + if (current_level_index != LEVEL_VELDIN1 && + (current_level_index != LEVEL_NOVALIS || level_available[3] != 0) && D_0015EE48 < 3) { level_render_state.state = LEVEL_RENDER_PHASE_SELECT_RANDOM_MODE; } if (level_render_state.state < LEVEL_RENDER_PHASE_REQUEST_LOAD) { @@ -330,8 +330,8 @@ void update_level_gameplay_frame(void) { qcopy(&level_render_state.secondary_history_positions[history_slot], &second_transform.rows[3]); if (level_render_state.mode == LEVEL_RENDER_MODE_FADE_OUT) { - if (current_level_index == 0 || - (current_level_index == 1 && level_available[3] == 0)) { + if (current_level_index == LEVEL_VELDIN1 || + (current_level_index == LEVEL_NOVALIS && level_available[3] == 0)) { interpolated_object->flags |= 1; level_render_state.history_count = 0; } diff --git a/src/game/update_mode_freeze.c b/src/game/update_mode_freeze.c index 2d22fcec8d..52c70596eb 100644 --- a/src/game/update_mode_freeze.c +++ b/src/game/update_mode_freeze.c @@ -50,16 +50,6 @@ void update_mode_freeze(void) { FREEZE_CHOICE_CONFIRM_EXIT = 2, FREEZE_CHOICE_CANCEL_EXIT = 3 }; - enum { - MODE_FREEZE_AWAIT_CROSS_RESUME = 2, - MODE_FREEZE_AWAIT_TRIANGLE_RESUME = 3, - MODE_FREEZE_BOOT_FLAGS_RELOAD_OR_RESUME = 4, - MODE_FREEZE_TRIANGLE_CLEAR_FLAGS_RESUME = 5, - MODE_FREEZE_BOOT_AWAIT_CLEAR_FLAGS_RESUME = 9, - MODE_FREEZE_FLAG_GATED_TRIANGLE_RESUME = 12, - MODE_FREEZE_RESUME_WITH_ACTION_LIST = 16, - MODE_FREEZE_BOOT_GATED_CROSS_RELOAD = 19 - }; enum { GAME_MODE_CONTINUE = 0, VIDEO_MODE_REQUEST_PAL_DISABLED = 0, @@ -84,7 +74,7 @@ void update_mode_freeze(void) { if (scale_game_frames(0x78) < state->unk20) { if (controller_state.pressed & PAD_CROSS) { game_mode = GAME_MODE_CONTINUE; - if (current_level_index == 1) { + if (current_level_index == LEVEL_NOVALIS) { memcard_save_data(0, -1); } } @@ -216,9 +206,9 @@ void update_mode_freeze(void) { } decrement_resource_counter(); if (scale_game_frames(0x1068) < hero.control_mode_timer) { - if (current_level_index == 5) { + if (current_level_index == LEVEL_RILGAR) { D_0015EE38++; - } else if (current_level_index == 0x10) { + } else if (current_level_index == LEVEL_KALEBO3) { D_0015EE3C++; } } @@ -243,8 +233,8 @@ void update_mode_freeze(void) { freeze.unk24--; } } - switch (mode_freeze_state) { - case MODE_FREEZE_AWAIT_CROSS_RESUME: + switch (save_card_state) { + case CS_WARNING: if (freeze.timer == 0) { if (controller_state.pressed & PAD_CROSS) { mode_freeze_flags &= ~1; @@ -253,7 +243,7 @@ void update_mode_freeze(void) { } break; - case 6: + case CS_PROMPT_FORMAT: if (controller_state.pressed & PAD_CIRCLE) { mode_freeze_flags |= 8; } else if (controller_state.pressed & PAD_TRIANGLE) { @@ -266,7 +256,7 @@ void update_mode_freeze(void) { } break; - case 13: + case CS_PROMPT_CREATE_SAVE: if (controller_state.pressed & PAD_CIRCLE) { mode_freeze_flags |= 0x10; } else if (controller_state.pressed & PAD_TRIANGLE) { @@ -279,13 +269,13 @@ void update_mode_freeze(void) { } break; - case 17: + case CS_FORMAT_FAILED: - case 18: + case CS_CREATE_FAILED: - case 20: + case CS_LOAD_FAILED: - case 21: + case CS_SAVE_FAILED: if (controller_state.pressed & PAD_CROSS) { mode_freeze_flags = mode_freeze_flags ^ 0x40; mode_freeze_flags = mode_freeze_flags & (~2); @@ -294,19 +284,19 @@ void update_mode_freeze(void) { } break; - case MODE_FREEZE_RESUME_WITH_ACTION_LIST: + case CS_NEWCARD: game_mode = freeze.return_game_mode; pause_current_action_list[0] = freeze.context; break; - case MODE_FREEZE_FLAG_GATED_TRIANGLE_RESUME: + case CS_NOSAVE: if (mode_freeze_flags & 2) { break; } - case MODE_FREEZE_AWAIT_TRIANGLE_RESUME: + case CS_NOCARD: - case MODE_FREEZE_TRIANGLE_CLEAR_FLAGS_RESUME: + case CS_UNFORMATTED: if (controller_state.pressed & PAD_TRIANGLE) { mode_freeze_flags = mode_freeze_flags & (~2); mode_freeze_flags = mode_freeze_flags & (~4); @@ -314,7 +304,7 @@ void update_mode_freeze(void) { } break; - case MODE_FREEZE_BOOT_GATED_CROSS_RELOAD: + case CS_NO_ROOM: if ((boot_level_active != 0) && (mode_freeze_flags & 2)) { if (controller_state.pressed & PAD_CROSS) { load_and_initialize_level_chunk(); @@ -335,9 +325,9 @@ void update_mode_freeze(void) { } break; - case 23: + case CS_PROMPT_BEGIN_UNFORMATTED: - case 24: + case CS_PROMPT_BEGIN_NOSAVE: if (controller_state.pressed & PAD_CROSS) { load_and_initialize_level_chunk(); mode_freeze_flags = mode_freeze_flags & (~2); @@ -351,7 +341,7 @@ void update_mode_freeze(void) { } break; - case MODE_FREEZE_BOOT_FLAGS_RELOAD_OR_RESUME: + case CS_WAIT_FOR_CARD: if (boot_level_active != 0) { if (mode_freeze_flags & 2) { struct PadState *pad = &controller_state; @@ -386,7 +376,7 @@ void update_mode_freeze(void) { } break; - case MODE_FREEZE_BOOT_AWAIT_CLEAR_FLAGS_RESUME: + case CS_FORMATTED: if (boot_level_active != 0) { if (!(mode_freeze_flags & 6)) { game_mode = freeze.return_game_mode; diff --git a/src/game/update_resident_gameplay_state.c b/src/game/update_resident_gameplay_state.c index 9edefe59b1..776fe7583a 100644 --- a/src/game/update_resident_gameplay_state.c +++ b/src/game/update_resident_gameplay_state.c @@ -279,30 +279,28 @@ void update_resident_gameplay_state(void) { keyframe_flags = keyframe->position.bytes[12]; view_tan_half_fov[0] = keyframe_angles[3]; update_view_context(); - qcopy(&preview_camera.position, &keyframe->position); - transform_vector_by_basis(&preview_camera.position, - &preview_camera.position, - level_render_state.player->transform); - fast_vec_add(&preview_camera.position, - &preview_camera.position, - &level_render_state.player->position); + qcopy(&game_camera.position, &keyframe->position); + transform_vector_by_basis( + &game_camera.position, &game_camera.position, level_render_state.player->transform); + fast_vec_add( + &game_camera.position, &game_camera.position, &level_render_state.player->position); segment_angle = fast_add_rotations(keyframe_angles[2], level_render_state.player->rotation.components[2]); sceVu0UnitMatrix(scratch_vectors); SceVu0RotMatrixX(scratch_vectors, scratch_vectors, keyframe->rotation[0]); SceVu0RotMatrixY(scratch_vectors, scratch_vectors, keyframe_angles[1]); sceVu0RotMatrixZ(scratch_vectors, scratch_vectors, segment_angle); - preview_camera.forward.f[0] = -scratch_vectors[2].components[0]; - preview_camera.right.f[0] = -scratch_vectors[0].components[0]; - preview_camera.up.f[0] = scratch_vectors[1].components[0]; - preview_camera.forward.f[1] = -scratch_vectors[2].components[1]; - preview_camera.right.f[1] = -scratch_vectors[0].components[1]; - preview_camera.up.f[1] = scratch_vectors[1].components[1]; - preview_camera.forward.f[2] = -scratch_vectors[2].components[2]; - preview_camera.right.f[2] = -scratch_vectors[0].components[2]; - preview_camera.up.f[2] = scratch_vectors[1].components[2]; + game_camera.forward.f[0] = -scratch_vectors[2].components[0]; + game_camera.right.f[0] = -scratch_vectors[0].components[0]; + game_camera.up.f[0] = scratch_vectors[1].components[0]; + game_camera.forward.f[1] = -scratch_vectors[2].components[1]; + game_camera.right.f[1] = -scratch_vectors[0].components[1]; + game_camera.up.f[1] = scratch_vectors[1].components[1]; + game_camera.forward.f[2] = -scratch_vectors[2].components[2]; + game_camera.right.f[2] = -scratch_vectors[0].components[2]; + game_camera.up.f[2] = scratch_vectors[1].components[2]; if (D_0015EDB4 != 0) { - fast_vec_cross(&preview_camera.right, &preview_camera.up, &preview_camera.forward); + fast_vec_cross(&game_camera.right, &game_camera.up, &game_camera.forward); } for (object_index = 0; object_index < render_sequence.count; object_index++) { playback_object = render_sequence.objects[object_index]; @@ -334,7 +332,7 @@ void update_resident_gameplay_state(void) { refresh_moby_spatial_bounds(playback_object); if (playback_object->class_id == 0) { if (level_render_state.state == LEVEL_RENDER_STATE_PLAYBACK_TO_MENU) { - if (current_level_index == 10 && item_available[6] == 0) { + if (current_level_index == LEVEL_ORXON && item_available[6] == 0) { playback_object->unk7F = 0; } else if (render_sequence.time <= scale_game_frames(0x3E)) { playback_object->unk7F = 0x18; @@ -342,7 +340,7 @@ void update_resident_gameplay_state(void) { playback_object->unk7F = 0; } } else if (scale_game_frames(360) < render_sequence.time) { - if (current_level_index == 10 && item_available[6] == 0) { + if (current_level_index == LEVEL_ORXON && item_available[6] == 0) { playback_object->unk7F = 0; } else { playback_object->unk7F = 0x18; @@ -371,8 +369,8 @@ void update_resident_gameplay_state(void) { } if (playback_object->class_id == 0) { noop_callback_e(playback_object); - if ((current_level_index == 10 && item_available[6] != 0) || - current_level_index == 13) { + if ((current_level_index == LEVEL_ORXON && item_available[6] != 0) || + current_level_index == LEVEL_OLTANIS_ORBIT) { if (level_render_state.attachment == 0) { level_render_state.attachment = create_moby(0x509); level_render_state.attachment->selected_index = 0x40; @@ -539,7 +537,7 @@ void update_resident_gameplay_state(void) { level_render_state.companion_b->lifetime_stamp = ((ResidentRenderObject *)hero.moby)->lifetime_stamp; } - noop_callback_a(&preview_camera.position, &preview_camera.rotation, 1, 0, 0); + noop_callback_a(&game_camera.position, &game_camera.rotation, 1, 0, 0); level_render_state.blend = 0.0f; level_render_state.interpolation_velocity = 0.0f; if (level_render_state.path >= 0) { diff --git a/src/overlays/l00/mobys/clank_cutscene_trigger.c b/src/overlays/l00/mobys/clank_cutscene_trigger.c index 7d5308dc9f..e64ab114ac 100644 --- a/src/overlays/l00/mobys/clank_cutscene_trigger.c +++ b/src/overlays/l00/mobys/clank_cutscene_trigger.c @@ -178,14 +178,14 @@ void apply_level_specific_cutscene_moby_effects(void) { VeldinVec joint_world_position; VeldinVec spherical_offset; - if (current_level_index == 0) { + if (current_level_index == LEVEL_VELDIN1) { for (i = 0; i < D_L00_0016C860.count; i++) { if (D_L00_0016C860.mobys[i]->oClass == 0x212) { add_draw_callback((s32)FUN_L00_002935b8, (s32)D_L00_0016C860.mobys[i]); } } } - if (current_level_index == 2) { + if (current_level_index == LEVEL_ARIDIA) { for (j = 0; j < D_L00_0016C860.count; j++) { mb = D_L00_0016C860.mobys[j]; if (mb->oClass == 0x1B1) { @@ -193,7 +193,7 @@ void apply_level_specific_cutscene_moby_effects(void) { } } } - if (current_level_index == 3 && D_L00_0016C860.state == 5 && + if (current_level_index == LEVEL_KERWAN && D_L00_0016C860.state == 5 && scale_game_frames(900) < D_L00_0016C860.timer && D_L00_0016C860.timer < scale_game_frames(1100)) { joint_position_source_moby = (char *)D_L00_0016C860.unk184; @@ -221,18 +221,18 @@ void apply_level_specific_cutscene_moby_effects(void) { } } } - if (current_level_index == 7 && D_L00_0016C860.state == 4 && D_L00_0016C860.unk188 != 0 && - D_L00_0016C860.unk188->oClass == 0x214) { + if (current_level_index == LEVEL_UMBRIS && D_L00_0016C860.state == 4 && + D_L00_0016C860.unk188 != 0 && D_L00_0016C860.unk188->oClass == 0x214) { add_draw_callback((s32)FUN_L00_002935b8, (s32)D_L00_0016C860.unk188); } - if (current_level_index == 14 && D_L00_0016C860.state == 0) { + if (current_level_index == LEVEL_OLTANIS && D_L00_0016C860.state == 0) { particle_source_moby = D_L00_0016C860.particle_pair_source_moby; if (particle_source_moby != 0 && (u32)(D_L00_0016C860.timer - 0x1C) < 6) { emit_moby_particle_pairs(particle_source_moby); add_draw_callback((s32)glow_quads_draw, (s32)particle_source_moby); } } - if (current_level_index == 15 && (u32)(D_L00_0016C860.state - 3) < 2) { + if (current_level_index == LEVEL_QUARTU && (u32)(D_L00_0016C860.state - 3) < 2) { for (k = 0; k < D_L00_0016C860.count; k++) { FUN_L00_00257024(D_L00_0016C860.mobys[k]); } diff --git a/src/overlays/l01/hero/hero_set_state.c b/src/overlays/l01/hero/hero_set_state.c index 26c2191426..2ac4e2dc90 100644 --- a/src/overlays/l01/hero/hero_set_state.c +++ b/src/overlays/l01/hero/hero_set_state.c @@ -74,7 +74,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { int old20A7; { struct Hero *p = &hero; - if (p->state.control_mode == 0x14 && + if (p->state.control_mode == HERO_MODE_DYING && (requested_state != HERO_STATE_IDLE_ANIMATION_WITH_DYING_OVERRIDE || animation_setup_mode != HERO_ANIMATION_ENTRY_OVERRIDE_GUARDS)) return 0; @@ -84,7 +84,8 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { return 0; { struct Hero *p = &hero; - if (p->health.hp == 0 && (p->state.control_mode == 2 || p->state.control_mode == 7) && + if (p->health.hp == 0 && + (p->state.control_mode == HERO_MODE_FALL || p->state.control_mode == HERO_MODE_HURT) && requested_state != HERO_STATE_FALL && requested_state != HERO_STATE_DYING && requested_state != HERO_STATE_VEHICLE_MODE_1_DYING && requested_state != HERO_STATE_VEHICLE_MODE_3_DYING && @@ -135,7 +136,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { switch (requested_state) { case HERO_STATE_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; p->unk1010 = random_int_between(scale_game_frames(0x32), scale_game_frames(0x64)); clear_hero_idle_rotation_targets(); @@ -164,7 +165,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_AT_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; clear_u64_value(&p->motion.momentum); p->rand_timer.range = 0x68; @@ -191,7 +192,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (animation_setup_mode) @@ -200,7 +201,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_DYING_SPEED_LIMITED: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -211,7 +212,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_SINK: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->unk694 = p->motion.displacement.f[2] * 0.2f; @@ -227,11 +228,11 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_SWIM: { struct Hero *p = &hero; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; *(int *)&p->drown_sink_speed = 0; - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } else { @@ -251,11 +252,11 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { case HERO_STATE_SWIM_WITH_CROUCH_INPUT: { struct Hero *p = &hero; int n; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; p->unk8F4 = scale_game_frames(0x3C); - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } @@ -271,7 +272,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { case HERO_STATE_SWIM_IDLE: { struct Hero *p = &hero; int n; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -285,11 +286,11 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_WATER_SURFACE_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; p->splash_effect_timer = 0; - if (p->state.prev_control_mode == 0x11) { + if (p->state.prev_control_mode == HERO_MODE_SWIM) { emit_hero_surface_effect_burst(3, 0xA, 0); if (pool_draw_tiles != 0) { pool_splash(pool_draw_tiles, @@ -317,7 +318,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { { struct Hero *q = &hero; q->unk698 = 0; - if (q->state.prev_control_mode == 0x11) { + if (q->state.prev_control_mode == HERO_MODE_SWIM) { if ((float)q->underwater_air < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); } else if ((float)q->underwater_air < 7500.0f) { @@ -325,7 +326,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } { struct Hero *r = &hero; - if (r->state.prev_control_mode == 0x11) { + if (r->state.prev_control_mode == HERO_MODE_SWIM) { if ((float)r->underwater_air < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); } else if ((float)r->underwater_air < 7500.0f) { @@ -356,7 +357,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->item_select_blocked = 1; @@ -389,7 +390,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_WATER_SURFACE_MOVE: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; *(int *)&p->drown_sink_speed = 0; @@ -401,7 +402,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_DROWN: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -443,7 +444,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_DYING_ZERO_HEALTH: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -455,7 +456,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { case HERO_STATE_LOOK: { struct Hero *p = &hero; int t; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 4; *(int *)&D_L01_0015F688 = scale_game_frames(0x3C); if (p->unk20AA == 0) { @@ -468,7 +469,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_ITEM_BUTTON_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(0xA)); @@ -477,7 +478,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_WAIT_FOR_ITEM_RELEASE_THEN_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(5)); @@ -486,7 +487,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_ITEM_BUTTON_HOLD_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.displacement); p->state.step = 0; @@ -499,9 +500,10 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { case HERO_STATE_DIRECTION_LIMITED_GROUND_MOVE: case HERO_STATE_SHALLOW_WATER_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; - if (p->state.prev_control_mode != 4 && p->state.prev2_control_mode != 4) { + if (p->state.prev_control_mode != HERO_MODE_JUMP && + p->state.prev2_control_mode != HERO_MODE_JUMP) { p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); } { @@ -512,7 +514,8 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { stick_target(1.0f, 0); if (1.5707964f < fast_difference_between_rotations(q->motion.rot.f[2], q->motion.move_yaw)) { - if (q->state.prev_control_mode == 7 || q->state.prev == 3 || q->state.prev2 == 3) { + if (q->state.prev_control_mode == HERO_MODE_HURT || q->state.prev == 3 || + q->state.prev2 == 3) { struct Hero *r = &hero; r->ground_speed = 0.0f; } @@ -545,7 +548,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { n = scale_game_frames(0x12); { struct Hero *u = &hero; - if (u->state.prev2_control_mode == 4 && + if (u->state.prev2_control_mode == HERO_MODE_JUMP && scale_game_frames(5) < u->rail_land_frames) n = scale_game_frames(0xD); } @@ -559,7 +562,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_APPROACH_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->item_use_locked = 1; @@ -590,7 +593,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_STOP: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (p->on_slip_ground != 0 && p->frames_off_ground.s == 0) { @@ -619,7 +622,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { case HERO_STATE_BRAKE_AT_TARGET_POSITION: { struct Hero *p = &hero; char *v = (char *)&p->motion.resolved_velocity; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = gravity_length_xy((float *)v); qcopy(&p->motion.momentum, v); @@ -634,7 +637,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_CROUCH: { struct Hero *p = &hero; - p->state.control_mode = 0xC; + p->state.control_mode = HERO_MODE_CROUCH; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); if (frame_time * 7.0f < p->ground_speed) @@ -675,11 +678,11 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 24.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -695,7 +698,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -705,7 +708,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_LEDGE_SHIMMY_POSITIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (animation_setup_mode) @@ -714,7 +717,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_LEDGE_SHIMMY_NEGATIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (animation_setup_mode) @@ -723,7 +726,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (animation_setup_mode) @@ -733,7 +736,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { case HERO_STATE_FALL: case HERO_STATE_FATAL_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -768,7 +771,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { case HERO_STATE_DELAYED_JUMP_OR_R1_REPEAT_EXIT_WAIT: { struct Hero *p = &hero; int animation_timing_override = -2; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk22CA = 1; p->rand_timer.range = 0x68; p->unk2284 = 0; @@ -784,7 +787,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { case HERO_STATE_LAND: { struct Hero *p = &hero; int animation_timing_override = -2; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->rand_timer.range = 0x68; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { @@ -822,7 +825,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { p->state_timer = p->state.prev_timer; return 0; } - p->state.control_mode = 4; + p->state.control_mode = HERO_MODE_JUMP; if (requested_state >= HERO_STATE_GRIND_JUMP && requested_state <= HERO_STATE_GRIND_RAIL_TRANSFER) { p->unk2284 = 3; @@ -1115,7 +1118,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } else if (s == 0xA) { set_hero_animation(0x12, 0, (float)scale_game_frames(5)); } else if (s == 0x10) { - if (q->state.prev_control_mode == 4 || + if (q->state.prev_control_mode == HERO_MODE_JUMP || (q->state.prev == 4 && scale_game_frames(7) > q->state_timer)) { set_hero_animation(0x26, 0, (float)scale_game_frames(8)); q->takeoff_frame += scale_game_frames(3); @@ -1147,7 +1150,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } { struct Hero *w = &hero; - if (w->state.prev_control_mode == 4) { + if (w->state.prev_control_mode == HERO_MODE_JUMP) { set_hero_animation(id, 1, (float)scale_game_frames(4)); w->takeoff_frame = scale_game_frames(1); } else { @@ -1166,7 +1169,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { case HERO_STATE_ANIMATION_RECOVERY_WITH_JUMP_CANCEL: case HERO_STATE_VEHICLE_MODE_1_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->speed_scale = 1.0f; p->unk2284 = 0; p->heading_locked = 0; @@ -1266,7 +1269,8 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { e = &D_L01_0017C0A8[q->attack_record]; q->saved_item[0] = 0; k = 0; - if (q->state.prev_control_mode == 6 && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { + if (q->state.prev_control_mode == HERO_MODE_ATTACK && e->unk0 == 0 && + q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 3; } { @@ -1352,7 +1356,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { case HERO_STATE_HURT: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->unk1EE = scale_game_frames(0x2D); @@ -1377,7 +1381,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_VEHICLE_MODE_3_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (animation_setup_mode) set_hero_animation(0, 0, (float)scale_game_frames(0xE)); @@ -1385,7 +1389,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_DELAYED_CIRCLE_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (animation_setup_mode) { set_hero_animation(4, 0, (float)scale_game_frames(7)); @@ -1395,7 +1399,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_VEHICLE_MODE_3_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (animation_setup_mode) @@ -1404,7 +1408,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_VEHICLE_MODE_3_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1415,7 +1419,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_VEHICLE_MODE_3_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; { char *v = (char *)&p->motion.resolved_velocity; @@ -1433,7 +1437,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_VEHICLE_MODE_3_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (animation_setup_mode) @@ -1442,7 +1446,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_VEHICLE_MODE_3_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1458,7 +1462,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_GRIND_COLLISION_RECOVERY: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 0; if (p->rail_off_frames == 0) hero_change_health(1); @@ -1485,7 +1489,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { case HERO_STATE_LOOK_RELEASE_WAIT: { struct Hero *p = &hero; p->unk2284 = 0x51; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; if (return_hero_animation_id_unchanged(p->moby->prev_seq) != get_hero_idle_animation_index(1)) { set_hero_animation(get_hero_idle_animation_index(1), 0, (float)scale_game_frames(5)); @@ -1510,7 +1514,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } case HERO_STATE_IDLE_ANIMATION_LONG_BLEND_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(0xA)); break; @@ -1576,7 +1580,8 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode != 0xF && t->items[1].item_id == 0x1D && t->saved_item[1] != 0) { + if (t->state.control_mode != HERO_MODE_GRIND && t->items[1].item_id == 0x1D && + t->saved_item[1] != 0) { t->restore_item[1] = 1; } } @@ -1588,7 +1593,7 @@ int l01_hero_set_state(int requested_state, int animation_setup_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode == 0x14) { + if (t->state.control_mode == HERO_MODE_DYING) { cancel_hero_item_animation(); t->item_use_locked = 1; } @@ -1651,7 +1656,7 @@ int handle_hero_gadget_button(void) { switch (hero.items[0].item_id) { case ITEM_WRENCH: if ((unsigned int)hero.state.control_mode < 2 || - (hero.state.control_mode == 4 && hero.rail_land_frames != 0)) { + (hero.state.control_mode == HERO_MODE_JUMP && hero.rail_land_frames != 0)) { if (hero.on_slip_ground == 0 && pad_pressed_within(buttons, scale_game_frames(7), &wrench_button_history_age) != 0) { @@ -1693,7 +1698,7 @@ int handle_hero_gadget_button(void) { l01_hero_set_state(0x13, 1); } } - } else if (hero.state.control_mode == 6) { + } else if (hero.state.control_mode == HERO_MODE_ATTACK) { row = &D_L01_0017C0A8[hero.attack_record]; if (hero.state.current == 0x15 && scale_game_frames(0x1e) < hero.state_timer && hero.anim_changing == 0 && (float)((int *)row)[4] <= hero.anim_frame && @@ -1727,17 +1732,20 @@ int handle_hero_gadget_button(void) { } break; case ITEM_REMOTE_VENDOR: - if ((unsigned int)hero.state.control_mode < 3 || hero.state.control_mode == 4 || - hero.state.control_mode == 5) { + if ((unsigned int)hero.state.control_mode < 3 || + hero.state.control_mode == HERO_MODE_JUMP || + hero.state.control_mode == HERO_MODE_LAND) { if (pad_pressed_within(buttons, scale_game_frames(8), 0) != 0) open_vendor_menu(0); } break; case 0xf: - if (hero.state.control_mode == 0 || hero.state.control_mode == 1 || - hero.state.control_mode == 0xc || hero.state.control_mode == 2 || - hero.state.control_mode == 4 || hero.state.control_mode == 5 || - hero.state.control_mode == 0xf || hero.state.current == 0x1e) { + if (hero.state.control_mode == HERO_MODE_IDLE || hero.state.control_mode == HERO_MODE_RUN || + hero.state.control_mode == HERO_MODE_CROUCH || + hero.state.control_mode == HERO_MODE_FALL || + hero.state.control_mode == HERO_MODE_JUMP || + hero.state.control_mode == HERO_MODE_LAND || + hero.state.control_mode == HERO_MODE_GRIND || hero.state.current == 0x1e) { if (hero.items[0].moby != 0) { equipped_gadget_vars = (struct HeldGadgetVars *)hero.items[0].moby->pvars; if ((((controller_state.held & buttons) != 0 && @@ -1759,10 +1767,12 @@ int handle_hero_gadget_button(void) { case 0x14: case 0x18: case 0x19: - if ((hero.state.control_mode == 0 && hero.state.current != 0x1e) || - hero.state.control_mode == 1 || hero.state.control_mode == 0xc || - hero.state.control_mode == 5 || hero.state.control_mode == 0xf || - (hero.state.control_mode == 4 && hero.unk4AC != 0) || + if ((hero.state.control_mode == HERO_MODE_IDLE && hero.state.current != 0x1e) || + hero.state.control_mode == HERO_MODE_RUN || + hero.state.control_mode == HERO_MODE_CROUCH || + hero.state.control_mode == HERO_MODE_LAND || + hero.state.control_mode == HERO_MODE_GRIND || + (hero.state.control_mode == HERO_MODE_JUMP && hero.unk4AC != 0) || (hero.state.current == 0x23 && hero.anim_frame > 25.0f)) { if (hero.item_anim_active == 0) { int hold; @@ -1774,9 +1784,10 @@ int handle_hero_gadget_button(void) { ((controller_state.held & 0x20) != 0 && scale_game_frames(8) < hold && hold < scale_game_frames(0x11))) { if (get_ammo(-1) != 0) { - if (hero.state.control_mode == 0xc || hero.state.control_mode == 0 || - hero.state.current == 3 || - (hero.state.control_mode == 1 && hero.stick_magnitude < 0.7f)) + if (hero.state.control_mode == HERO_MODE_CROUCH || + hero.state.control_mode == HERO_MODE_IDLE || hero.state.current == 3 || + (hero.state.control_mode == HERO_MODE_RUN && + hero.stick_magnitude < 0.7f)) l01_hero_set_state(0x23, 1); else start_equipped_item_animation(); @@ -1788,8 +1799,8 @@ int handle_hero_gadget_button(void) { } break; case 0x12: - if (hero.state.control_mode == 0 || hero.state.control_mode == 1 || - (hero.state.control_mode == 4 && hero.rail_land_frames != 0)) { + if (hero.state.control_mode == HERO_MODE_IDLE || hero.state.control_mode == HERO_MODE_RUN || + (hero.state.control_mode == HERO_MODE_JUMP && hero.rail_land_frames != 0)) { if (hero.state.current != 1) { int limit = scale_game_frames(10); int hold = hero.items[0].ready_frames; @@ -1814,8 +1825,10 @@ int handle_hero_gadget_button(void) { (hero.unk308 == 0 || D_0013D4DC[0] == 0) && hero.pack_disabled == 0) { fast_dec_timer(&r1_double_tap_timer); if (r1_double_tap_timer != 0 && - ((unsigned int)hero.state.control_mode < 2 || hero.state.control_mode == 0xc || - ((hero.state.control_mode == 2 || hero.state.control_mode == 4) && + ((unsigned int)hero.state.control_mode < 2 || + hero.state.control_mode == HERO_MODE_CROUCH || + ((hero.state.control_mode == HERO_MODE_FALL || + hero.state.control_mode == HERO_MODE_JUMP) && hero.grounded_frames != 0)) && (controller_state.held & 8) != 0 && (controller_state.pressed & 8) != 0) l01_hero_set_state(0x81, 1); diff --git a/src/overlays/l01/hero/update_hero_motion_for_current_state.c b/src/overlays/l01/hero/update_hero_motion_for_current_state.c index eafef45818..6bfeff6851 100644 --- a/src/overlays/l01/hero/update_hero_motion_for_current_state.c +++ b/src/overlays/l01/hero/update_hero_motion_for_current_state.c @@ -296,7 +296,7 @@ void update_hero_airborne_planar_motion(void) { qcopy(&hero.motion.momentum, &hero.move_impulse); air_acceleration = frame_time_sq * 20.0f; if (hero.target_speed < hero_air_control_speed_reference[0] * frame_time * 0.2f) { - if (hero.state.control_mode == 2) { + if (hero.state.control_mode == HERO_MODE_FALL) { speed_decay_step = hero.stickless_decel; speed = vector_length_xy(&hero.motion.velocity); approach_value(0.0f, speed_decay_step, &speed); @@ -489,7 +489,7 @@ void update_hero_motion_for_current_state(void) { *(OvlQuad *)vector_and_hit_scratch[0] = 0; vector_and_hit_scratch[0][0] = 1.0f; transform_vector_by_basis( - hero.motion.move_dir.f, vector_and_hit_scratch[0], l01_camera.unk350); + hero.motion.move_dir.f, vector_and_hit_scratch[0], l01_camera.rows); hero.motion.move_yaw = l01_camera.yaw; turn_to(0, frame_scale_sq, frame_scale_sq * 0.0f, frame_time * 174.53293f); if (*(int *)&D_L01_0015F688 > 0) { @@ -1699,12 +1699,12 @@ void update_hero_motion_for_current_state(void) { } } break; case HERO_STATE_VOICE_SLOT_CLEANUP_IDLE_EXIT: - if (current_level_index == 0xF) { + if (current_level_index == LEVEL_QUARTU) { release_voice_slot_cf(2, (int)hero.moby, 0x1D); } else { release_voice_slot_cf(2, (int)hero.moby, 6); } - if (current_level_index != 0xF) { + if (current_level_index != LEVEL_QUARTU) { emit_hero_randomized_motion_effects(4, 2); vector_and_hit_scratch[0][0] = hero.motion.pos.f[0] + random_float_between(-0.25f, 0.25f); diff --git a/src/overlays/l01/hero/update_hero_state_machine.c b/src/overlays/l01/hero/update_hero_state_machine.c index badbb2d55b..3fe3b68ffa 100644 --- a/src/overlays/l01/hero/update_hero_state_machine.c +++ b/src/overlays/l01/hero/update_hero_state_machine.c @@ -157,7 +157,7 @@ void update_hero_state_machine(void) { prevState = hero.state.step; prevAnim = MOBY(moby)->prev_seq; if (process_hero_hit_response(1) == 0) { - if (hero.health.hp <= 0 && hero.state.control_mode != 0x14 && + if (hero.health.hp <= 0 && hero.state.control_mode != HERO_MODE_DYING && (hero.state.current == HERO_STATE_IDLE || hero.state.current == HERO_STATE_RUN)) { l01_hero_set_state(HERO_STATE_DYING, 1); } else if (handle_hero_gadget_button() == 0 && try_enter_hero_water_state() == 0 && @@ -412,7 +412,7 @@ void update_hero_state_machine(void) { } } if (ok && 0.22f < hero.stick_magnitude) { - if (current_level_index == 0xC) { + if (current_level_index == LEVEL_HOVEN) { int slot = hero.ground_sound_class; request_hero_voice_if_enabled(slot, 0, 0); request_hero_voice_if_enabled(slot, 1, 0); @@ -603,7 +603,8 @@ void update_hero_state_machine(void) { break; case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: if (hero.health.hp <= 0) { - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || + current_level_index == LEVEL_VELDIN_ORBIT) { l01_hero_set_state(0x82, 1); break; } @@ -781,7 +782,8 @@ void update_hero_state_machine(void) { break; } if (!(hero.air_frames.s < scale_game_frames(5)) && - !(hero.state.prev_control_mode == 0x12 && hero.wading != 0) && + !(hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE && + hero.wading != 0) && hero.ground_distance > 1.35f) { if (check_hero_forward_collision_height() == 0) { l01_hero_set_state(HERO_STATE_FALL, 1); @@ -841,7 +843,8 @@ void update_hero_state_machine(void) { } } if (hero.state_timer > scale_game_frames(0xF) || - (hero.state.prev_control_mode != 0 && hero.state.prev_control_mode != 1)) { + (hero.state.prev_control_mode != HERO_MODE_IDLE && + hero.state.prev_control_mode != HERO_MODE_RUN)) { if ((controller_state.pressed & 0x10000) && hero.unk20AA == 0) { hero.unk3BE = 1; } @@ -1298,9 +1301,9 @@ void update_hero_state_machine(void) { } break; case HERO_STATE_FATAL_FALL: - if ((current_level_index == 3 && 5.0f > hero.motion.pos.f[2]) || - (current_level_index == 6 && 50.0f > hero.motion.pos.f[2]) || - (current_level_index == 0x10 && + if ((current_level_index == LEVEL_KERWAN && 5.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_NEBULA_G34 && 50.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_KALEBO3 && (77.0f > hero.motion.pos.f[2] || (hero.state_timer > 0x14 && hero.wall_hit != 0 && hero.motion.displacement.f[2] >= 0.0f))) || diff --git a/src/overlays/l01/mobys/help_hints.c b/src/overlays/l01/mobys/help_hints.c index cb20b872ef..98bc411af4 100644 --- a/src/overlays/l01/mobys/help_hints.c +++ b/src/overlays/l01/mobys/help_hints.c @@ -128,7 +128,7 @@ void help_hints_update(struct Moby *moby) { } } } - if (hero.state.control_mode == 0x12 && tutorial_hint_vars[10] == 0 && + if (hero.state.control_mode == HERO_MODE_WATER_SURFACE && tutorial_hint_vars[10] == 0 && help_state.state == HELP_STATE_INACTIVE && help_state.cur == -1 && (is_point_inside_clip_volume(&hero.motion.pos, tutorial_hint_vars[8]) || is_point_inside_clip_volume(&hero.motion.pos, tutorial_hint_vars[9]))) { @@ -162,7 +162,7 @@ void help_hints_update(struct Moby *moby) { usage_stats.stat[23].level_mask = usage_stats.stat[23].level_mask | (1 << current_level_index_macro) | 0x80000000; } - } else if (hero.state.control_mode == 0x11) { + } else if (hero.state.control_mode == HERO_MODE_SWIM) { help_records[0x44].count = 0xFFFF; } else { tutorial_hint_vars[11] = 0; diff --git a/src/overlays/l01/mobys/spark_particle_emitter.c b/src/overlays/l01/mobys/spark_particle_emitter.c index 0783a7d5df..a31101df07 100644 --- a/src/overlays/l01/mobys/spark_particle_emitter.c +++ b/src/overlays/l01/mobys/spark_particle_emitter.c @@ -85,7 +85,7 @@ void spark_particle_emitter_update(EmitterMoby *emitter_moby) { s32 i; emitter_vars = emitter_moby->vars; - if (current_level_index == 1) { + if (current_level_index == LEVEL_NOVALIS) { position_scratch.q = emitter_moby->pos.q; position_scratch.f[3] = 20.0f; if (fast_bsphere_check(&position_scratch, 240.0f) == -1) { diff --git a/src/overlays/l01/mobys/water_current.c b/src/overlays/l01/mobys/water_current.c index 45d9fe9f34..b3d77b1e28 100644 --- a/src/overlays/l01/mobys/water_current.c +++ b/src/overlays/l01/mobys/water_current.c @@ -68,8 +68,9 @@ void water_current_update(struct Moby *water_current_moby) { water_current_moby->update_dist = 0xFF; } - if ((u32)(hero.state.control_mode - 0x11) >= 2 && hero.state.prev_control_mode != 0x11 && - hero.state.prev_control_mode != 0x12 && hero.state.current != 0x12 && + if ((u32)(hero.state.control_mode - 0x11) >= 2 && + hero.state.prev_control_mode != HERO_MODE_SWIM && + hero.state.prev_control_mode != HERO_MODE_WATER_SURFACE && hero.state.current != 0x12 && hero.state.prev != 0x12) { return; } @@ -114,7 +115,8 @@ void water_current_update(struct Moby *water_current_moby) { current_speed); qcopy(&hero.motion.platform_delta, water_current_vars); } - if (hero.state.control_mode == 0x12 && hero.state.prev == hero.state.control_mode) { + if (hero.state.control_mode == HERO_MODE_WATER_SURFACE && + hero.state.prev == hero.state.control_mode) { if (hero.state_timer < scale_game_frames(3)) { cap = frame_time * 1.5f; if (cap < hero.ground_speed) { @@ -123,7 +125,8 @@ void water_current_update(struct Moby *water_current_moby) { clear_u64_value(&hero.motion.momentum); } } - } else if ((hero.state.prev_control_mode == 0x12 || hero.state.prev2_control_mode == 0x12) && + } else if ((hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE || + hero.state.prev2_control_mode == HERO_MODE_WATER_SURFACE) && (u32)(hero.state.control_mode - 4) < 2) { current_speed = fast_vec_length(water_current_vars); fast_vec_normalize(water_current_vars, diff --git a/src/overlays/l02/draw_sky_with_gif_paging.c b/src/overlays/l02/draw_sky_with_gif_paging.c index 25c276826f..1b252774a7 100644 --- a/src/overlays/l02/draw_sky_with_gif_paging.c +++ b/src/overlays/l02/draw_sky_with_gif_paging.c @@ -12,7 +12,7 @@ void draw_sky_with_gif_paging(void) __asm__("FUN_L02_00240048"); void draw_sky_with_gif_paging(void) { setup_sky_gif_paging(); - if (current_level_index == 0x2) { + if (current_level_index == LEVEL_ARIDIA) { draw_four_sky_shells_with_animated_particles(); } else { update_sky_shells_static(); diff --git a/src/overlays/l02/hero/hero_set_state.c b/src/overlays/l02/hero/hero_set_state.c index d38a0568db..42a7285fec 100644 --- a/src/overlays/l02/hero/hero_set_state.c +++ b/src/overlays/l02/hero/hero_set_state.c @@ -75,7 +75,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { int old20A7; { struct Hero *p = &hero; - if (p->state.control_mode == 0x14 && + if (p->state.control_mode == HERO_MODE_DYING && (requested_state != HERO_STATE_IDLE_ANIMATION_WITH_DYING_OVERRIDE || entry_animation_mode != HERO_ANIMATION_ENTRY_OVERRIDE_GUARDS)) return 0; @@ -85,7 +85,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { return 0; { struct Hero *p = &hero; - if (p->health.hp == 0 && (p->state.control_mode == 2 || p->state.control_mode == 7) && + if (p->health.hp == 0 && + (p->state.control_mode == HERO_MODE_FALL || p->state.control_mode == HERO_MODE_HURT) && requested_state != HERO_STATE_FALL && requested_state != HERO_STATE_DYING && requested_state != HERO_STATE_VEHICLE_MODE_1_DYING && requested_state != HERO_STATE_VEHICLE_MODE_3_DYING && @@ -136,7 +137,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { switch (requested_state) { case HERO_STATE_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; p->unk1010 = random_int_between(scale_game_frames(0x32), scale_game_frames(0x64)); clear_hero_idle_rotation_targets(); @@ -165,7 +166,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_AT_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; clear_u64_value(&p->motion.momentum); p->rand_timer.range = 0x68; @@ -192,7 +193,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -201,7 +202,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DYING_SPEED_LIMITED: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -212,7 +213,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_SINK: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->unk694 = p->motion.displacement.f[2] * 0.2f; @@ -229,7 +230,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_LOOK: { struct Hero *p = &hero; int t; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 4; *(int *)&D_L02_0015F688 = scale_game_frames(0x3C); if (p->unk20AA == 0) { @@ -242,7 +243,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ITEM_BUTTON_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(0xA)); @@ -251,7 +252,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_WAIT_FOR_ITEM_RELEASE_THEN_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(5)); @@ -260,7 +261,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ITEM_BUTTON_HOLD_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.displacement); p->state.step = 0; @@ -273,9 +274,10 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_DIRECTION_LIMITED_GROUND_MOVE: case HERO_STATE_SHALLOW_WATER_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; - if (p->state.prev_control_mode != 4 && p->state.prev2_control_mode != 4) { + if (p->state.prev_control_mode != HERO_MODE_JUMP && + p->state.prev2_control_mode != HERO_MODE_JUMP) { p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); } { @@ -286,7 +288,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { stick_target(1.0f, 0); if (1.5707964f < fast_difference_between_rotations(q->motion.rot.f[2], q->motion.move_yaw)) { - if (q->state.prev_control_mode == 7 || q->state.prev == 3 || q->state.prev2 == 3) { + if (q->state.prev_control_mode == HERO_MODE_HURT || q->state.prev == 3 || + q->state.prev2 == 3) { struct Hero *r = &hero; r->ground_speed = 0.0f; } @@ -319,7 +322,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { n = scale_game_frames(0x12); { struct Hero *u = &hero; - if (u->state.prev2_control_mode == 4 && + if (u->state.prev2_control_mode == HERO_MODE_JUMP && scale_game_frames(5) < u->rail_land_frames) n = scale_game_frames(0xD); } @@ -333,7 +336,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ANIMATION_FRAME_EXIT_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; if (entry_animation_mode) { if (p->state.prev == 4) { @@ -346,7 +349,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_APPROACH_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->item_use_locked = 1; @@ -366,7 +369,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_STOP: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (p->on_slip_ground != 0 && p->frames_off_ground.s == 0) { @@ -395,7 +398,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_BRAKE_AT_TARGET_POSITION: { struct Hero *p = &hero; char *v = (char *)&p->motion.resolved_velocity; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = gravity_length_xy((float *)v); qcopy(&p->motion.momentum, v); @@ -410,7 +413,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_CROUCH: { struct Hero *p = &hero; - p->state.control_mode = 0xC; + p->state.control_mode = HERO_MODE_CROUCH; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); if (frame_time * 7.0f < p->ground_speed) @@ -439,7 +442,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_GRAPPLE_TARGET_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -461,7 +464,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_APPROACH_TARGET_MOBY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; *(int *)&p->grapple_pull_speed = 0; p->grapple_pull_ending = 0; @@ -472,7 +475,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_CONSTRAIN_TO_TARGET_RADIUS: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; p->item_use_locked = 1; *(int *)&p->grapple_pull_speed = 0; @@ -485,7 +488,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_GRAPPLE_SWING_ENTRY: { struct Hero *p = &hero; char *d; - p->state.control_mode = 0xE; + p->state.control_mode = HERO_MODE_GRAPPLE_SWING; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -529,9 +532,9 @@ int hero_set_state(int requested_state, int entry_animation_mode) { q->swing_target_moby->pos.y - q->motion.pos.f[1]); q->unk9A4 = fast_vec_dist(&q->motion.pos, &q->swing_target_moby->pos); q->swing_gravity = frame_time_sq * 27.0f; - if (q->state.prev_control_mode == 4) { + if (q->state.prev_control_mode == HERO_MODE_JUMP) { q->swing_gravity = q->jump_gravity; - } else if (q->state.prev_control_mode == 2) { + } else if (q->state.prev_control_mode == HERO_MODE_FALL) { q->swing_gravity = q->fall_state_gravity; } if (entry_animation_mode) { @@ -546,7 +549,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ITEM_RELEASE_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 7; clear_u64_value(&p->motion.rot_spring_vel); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -568,11 +571,11 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 24.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -588,7 +591,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -598,7 +601,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_SHIMMY_POSITIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (entry_animation_mode) @@ -607,7 +610,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_SHIMMY_NEGATIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (entry_animation_mode) @@ -616,7 +619,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -626,7 +629,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_FALL: case HERO_STATE_FATAL_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -661,7 +664,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_DELAYED_JUMP_OR_R1_REPEAT_EXIT_WAIT: { struct Hero *p = &hero; int animation_timing_selector = -2; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk22CA = 1; p->rand_timer.range = 0x68; p->unk2284 = 0; @@ -677,7 +680,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_LAND: { struct Hero *p = &hero; int animation_timing_selector = -2; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->rand_timer.range = 0x68; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { @@ -715,7 +718,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { p->state_timer = p->state.prev_timer; return 0; } - p->state.control_mode = 4; + p->state.control_mode = HERO_MODE_JUMP; if (requested_state >= HERO_STATE_GRIND_JUMP && requested_state <= HERO_STATE_GRIND_RAIL_TRANSFER) { p->unk2284 = 3; @@ -778,7 +781,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { u->fall_gravity = u->jump_gravity * 1.17f; } else if (u->state.current == 0x69) { float v; - u->state.control_mode = 0x19; + u->state.control_mode = HERO_MODE_RESPAWN_WAIT; if (u->motion.pos.f[2] < u->sink_surface_z) { v = u->sink_surface_z - u->motion.pos.f[2]; } else { @@ -1000,7 +1003,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } else if (s == 0xA) { set_hero_animation(0x12, 0, (float)scale_game_frames(5)); } else if (s == 0x10) { - if (q->state.prev_control_mode == 4 || + if (q->state.prev_control_mode == HERO_MODE_JUMP || (q->state.prev == 4 && scale_game_frames(7) > q->state_timer)) { set_hero_animation(0x26, 0, (float)scale_game_frames(8)); q->takeoff_frame += scale_game_frames(3); @@ -1032,7 +1035,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *w = &hero; - if (w->state.prev_control_mode == 4) { + if (w->state.prev_control_mode == HERO_MODE_JUMP) { set_hero_animation(id, 1, (float)scale_game_frames(4)); w->takeoff_frame = scale_game_frames(1); } else { @@ -1051,7 +1054,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_ANIMATION_RECOVERY_WITH_JUMP_CANCEL: case HERO_STATE_VEHICLE_MODE_1_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->speed_scale = 1.0f; p->unk2284 = 0; p->heading_locked = 0; @@ -1151,7 +1154,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { e = &D_L02_0017C228[q->attack_record]; q->saved_item[0] = 0; k = 0; - if (q->state.prev_control_mode == 6 && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { + if (q->state.prev_control_mode == HERO_MODE_ATTACK && e->unk0 == 0 && + q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 3; } { @@ -1206,7 +1210,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ATTACK_RECORD_FRAME_EXIT_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unkA64 = 0; if (p->state.prev == 0x70) { int v = 5; @@ -1264,7 +1268,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_HURT: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->unk1EE = scale_game_frames(0x2D); @@ -1290,7 +1294,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_WAIT_FOR_JUMP_OR_RESPAWN: { struct Hero *p = &hero; if (p->state.prev == 0x69 || - (p->state.prev2 == 0x69 && p->state.prev_control_mode != 0 && p->state.prev != 7)) { + (p->state.prev2 == 0x69 && p->state.prev_control_mode != HERO_MODE_IDLE && + p->state.prev != 7)) { p->sink_jump_count = p->sink_jump_count + 1; } else { struct Hero *q = &hero; @@ -1298,7 +1303,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *r = &hero; - r->state.control_mode = 0x19; + r->state.control_mode = HERO_MODE_RESPAWN_WAIT; r->unk2284 = 0; allocate_hero_voice_for_entry(9, 0); r->rand_timer.range = 0x68; @@ -1311,9 +1316,9 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_HEIGHT_OR_TIMEOUT_RESPAWN_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0x19; + p->state.control_mode = HERO_MODE_RESPAWN_WAIT; p->unk2284 = 0; - if (current_level_index == 0xF) + if (current_level_index == LEVEL_QUARTU) spawn_hero_radial_particle_burst(); p->collision_off_frames = 0x2710; allocate_hero_voice_for_entry(9, 0); @@ -1324,7 +1329,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (entry_animation_mode) set_hero_animation(0, 0, (float)scale_game_frames(0xE)); @@ -1332,7 +1337,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DELAYED_CIRCLE_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (entry_animation_mode) { set_hero_animation(4, 0, (float)scale_game_frames(7)); @@ -1342,7 +1347,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -1351,7 +1356,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1362,7 +1367,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; { char *v = (char *)&p->motion.resolved_velocity; @@ -1380,7 +1385,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -1389,7 +1394,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1405,7 +1410,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_GRIND_COLLISION_RECOVERY: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 0; if (p->rail_off_frames == 0) hero_change_health(1); @@ -1432,7 +1437,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_LOOK_RELEASE_WAIT: { struct Hero *p = &hero; p->unk2284 = 0x51; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; if (return_hero_animation_id_unchanged(p->moby->prev_seq) != get_hero_idle_animation_index(1)) { set_hero_animation(get_hero_idle_animation_index(1), 0, (float)scale_game_frames(5)); @@ -1457,7 +1462,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_IDLE_ANIMATION_LONG_BLEND_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(0xA)); break; @@ -1509,7 +1514,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode != 0xF && t->items[1].item_id == 0x1D && t->saved_item[1] != 0) { + if (t->state.control_mode != HERO_MODE_GRIND && t->items[1].item_id == 0x1D && + t->saved_item[1] != 0) { t->restore_item[1] = 1; } } @@ -1521,7 +1527,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode == 0x14) { + if (t->state.control_mode == HERO_MODE_DYING) { cancel_hero_item_animation(); t->item_use_locked = 1; } @@ -1866,7 +1872,7 @@ void update_hero_state_transitions(void) { prevState = hero.state.step; prevAnim = moby[0x53]; if (process_hero_hurt_response(1) == 0) { - if (hero.health.hp <= 0 && hero.state.control_mode != 0x14 && + if (hero.health.hp <= 0 && hero.state.control_mode != HERO_MODE_DYING && (hero.state.current == HERO_STATE_IDLE || hero.state.current == HERO_STATE_RUN)) { hero_set_state(HERO_STATE_DYING, 1); } else if (process_hero_item_action_input() == 0 && @@ -2119,7 +2125,7 @@ void update_hero_state_transitions(void) { } } if (ok && 0.22f < hero.stick_magnitude) { - if (current_level_index == 0xC) { + if (current_level_index == LEVEL_HOVEN) { int slot = hero.ground_sound_class; request_hero_voice_if_enabled(slot, 0, 0); request_hero_voice_if_enabled(slot, 1, 0); @@ -2347,7 +2353,8 @@ void update_hero_state_transitions(void) { break; } if (!(hero.air_frames.s < scale_game_frames(5)) && - !(hero.state.prev_control_mode == 0x12 && hero.wading != 0) && + !(hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE && + hero.wading != 0) && hero.ground_distance > 1.35f) { if (check_hero_forward_collision_height() == 0) { hero_set_state(HERO_STATE_FALL, 1); @@ -2401,7 +2408,8 @@ void update_hero_state_transitions(void) { hero_set_state(0x3F, 1); } if (hero.state_timer > scale_game_frames(0xF) || - (hero.state.prev_control_mode != 0 && hero.state.prev_control_mode != 1)) { + (hero.state.prev_control_mode != HERO_MODE_IDLE && + hero.state.prev_control_mode != HERO_MODE_RUN)) { if ((controller_state.pressed & 0x10000) && hero.unk20AA == 0) { hero.unk3BE = 1; } @@ -2969,9 +2977,9 @@ void update_hero_state_transitions(void) { } break; case HERO_STATE_FATAL_FALL: - if ((current_level_index == 3 && 5.0f > hero.motion.pos.f[2]) || - (current_level_index == 6 && 50.0f > hero.motion.pos.f[2]) || - (current_level_index == 0x10 && + if ((current_level_index == LEVEL_KERWAN && 5.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_NEBULA_G34 && 50.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_KALEBO3 && (77.0f > hero.motion.pos.f[2] || (hero.state_timer > 0x14 && hero.wall_hit != 0 && hero.motion.displacement.f[2] >= 0.0f))) || diff --git a/src/overlays/l02/hero/update_hero_state_motion.c b/src/overlays/l02/hero/update_hero_state_motion.c index a660f4e646..e2a3d1befd 100644 --- a/src/overlays/l02/hero/update_hero_state_motion.c +++ b/src/overlays/l02/hero/update_hero_state_motion.c @@ -183,10 +183,10 @@ s32 process_hero_hurt_response(s32 apply_hurt_response) { f32 planar_impulse_scale, vertical_impulse_scale, cached_frame_time; OvlVec4 hurt_impulse; - if (G.state.control_mode == 0x14) { + if (G.state.control_mode == HERO_MODE_DYING) { return 0; } - if (G.state.control_mode == 7) { + if (G.state.control_mode == HERO_MODE_HURT) { return 0; } if (G.state.current == 0x32) { @@ -287,7 +287,7 @@ void update_hero_collision_dimensions(void) { hero.capsule_radius_target = 0.45f; break; } - if (hero.state.control_mode == 4) { + if (hero.state.control_mode == HERO_MODE_JUMP) { if (hero.state_timer > hero.takeoff_frame && hero.past_jump_apex == 0) hero.capsule_bottom_target = hero.unk434; } else if (hero.state.current == HERO_STATE_FALL) { @@ -297,8 +297,8 @@ void update_hero_collision_dimensions(void) { } else if (hero.state.current == HERO_STATE_SINK) { hero.capsule_radius_target = 0.8f; } - if (!hero.wall_hit || hero.state.prev_control_mode == 0x12 || hero.state.control_mode == 0x11 || - hero.base_condition || + if (!hero.wall_hit || hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE || + hero.state.control_mode == HERO_MODE_SWIM || hero.base_condition || vector_distance_xy(hero.wall_contact_point.f, hero.motion.pos.f) > hero.capsule_radius * 0.5f) { f32 *hero_smoothed_values = D_0013F570; @@ -372,7 +372,7 @@ void update_hero_ground_contact(void) { if (hero.gravity_mode) k = 1; collision_ray_start_offset = hero.capsule_radius * 2.2f; - if (hero.state.control_mode == 2) { + if (hero.state.control_mode == HERO_MODE_FALL) { collision_ray_start_offset = hero.capsule_radius * 2.9f; } hero_get_collision_ray_endpoints( @@ -397,7 +397,7 @@ void update_hero_ground_contact(void) { goto d1; } collision_sound_class = coll_sound_class(); - if (current_level_index == 1 || current_level_index == 0x12) { + if (current_level_index == LEVEL_NOVALIS || current_level_index == LEVEL_VELDIN2) { collision_sound_class = 3; } hero.ground_sound_class = collision_sound_class; @@ -485,9 +485,9 @@ void update_hero_ground_contact(void) { hero.unk2C8.i[1] = 0; hero.unk2C0.i[0] = 0; hero.unk2C0.i[1] = 0; - if (hero.state.control_mode == 0xF || hero.state.control_mode == 0x15 || - hero.state.control_mode == 6 || hero.state.control_mode == 4 || - hero.state.control_mode == 5 || hero.state.control_mode == 3) { + if (hero.state.control_mode == HERO_MODE_GRIND || hero.state.control_mode == 0x15 || + hero.state.control_mode == HERO_MODE_ATTACK || hero.state.control_mode == HERO_MODE_JUMP || + hero.state.control_mode == HERO_MODE_LAND || hero.state.control_mode == HERO_MODE_LEDGE) { return; } if (!(hero.ground_distance < 0.25f)) { @@ -593,7 +593,7 @@ s32 resolve_hero_position_collisions(s32 mode) { resolve_hero_pending_path_clearance(); hero.path_constrain_pending = 0; } - if (hero.state.control_mode != 0x11) { + if (hero.state.control_mode != HERO_MODE_SWIM) { if (hero.gravity_mode != HERO_GRAVITY_WORLD_DOWN || hero.unk1F8 != 0) { if (hero.gravity_mode == HERO_GRAVITY_OPPOSITE_GROUND_NORMAL || hero.unk1F8 != 0) { add_hero_up_offset(&collision_probe_offset, &collision_probe_offset, 0.6f); @@ -811,7 +811,7 @@ void update_hero_state_motion(void) { *(OvlQuad *)motion_geometry_scratch[0] = 0; motion_geometry_scratch[0][0] = 1.0f; transform_vector_by_basis( - hero.motion.move_dir.f, motion_geometry_scratch[0], l02_camera.unk350); + hero.motion.move_dir.f, motion_geometry_scratch[0], l02_camera.rows); hero.motion.move_yaw = l02_camera.yaw; turn_to(0, frame_scale_sq, frame_scale_sq * 0.0f, frame_time * 174.53293f); if (*(int *)&D_L02_0015F688 > 0) { diff --git a/src/overlays/l02/set_sonic_summoner_moby_flag_0800.c b/src/overlays/l02/set_sonic_summoner_moby_flag_0800.c index 11ed0be9c0..c4b13e1da4 100644 --- a/src/overlays/l02/set_sonic_summoner_moby_flag_0800.c +++ b/src/overlays/l02/set_sonic_summoner_moby_flag_0800.c @@ -24,7 +24,7 @@ void set_sonic_summoner_moby_flag_0800(void) __asm__("FUN_L02_002400c void set_sonic_summoner_moby_flag_0800(void) { int i; - if (current_level_index == 2) { + if (current_level_index == LEVEL_ARIDIA) { for (i = 0; i < talk_camera.count; i++) { Level02Moby *moby = talk_camera.mobys[i]; if (moby->class_id == 0x1B1) { diff --git a/src/overlays/l03/cutscene_sparks.c b/src/overlays/l03/cutscene_sparks.c index c4e15cf769..1574743621 100644 --- a/src/overlays/l03/cutscene_sparks.c +++ b/src/overlays/l03/cutscene_sparks.c @@ -23,7 +23,7 @@ void emit_cutscene_sparks(void) { float world_position[4]; float spherical_offset[4]; int i; - if (current_level_index != 3) + if (current_level_index != LEVEL_KERWAN) return; level_state = D_L03_0016C960; if (*(int *)(level_state + 0x30) != 5) diff --git a/src/overlays/l03/hero/hero_set_state.c b/src/overlays/l03/hero/hero_set_state.c index 9678fe9c3b..f0fa191cbf 100644 --- a/src/overlays/l03/hero/hero_set_state.c +++ b/src/overlays/l03/hero/hero_set_state.c @@ -74,7 +74,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { int old20A7; { struct Hero *p = &hero; - if (p->state.control_mode == 0x14 && + if (p->state.control_mode == HERO_MODE_DYING && (requested_state != HERO_STATE_IDLE_ANIMATION_WITH_DYING_OVERRIDE || entry_animation_mode != HERO_ANIMATION_ENTRY_OVERRIDE_GUARDS)) return 0; @@ -84,7 +84,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { return 0; { struct Hero *p = &hero; - if (p->health.hp == 0 && (p->state.control_mode == 2 || p->state.control_mode == 7) && + if (p->health.hp == 0 && + (p->state.control_mode == HERO_MODE_FALL || p->state.control_mode == HERO_MODE_HURT) && requested_state != HERO_STATE_FALL && requested_state != HERO_STATE_DYING && requested_state != HERO_STATE_VEHICLE_MODE_1_DYING && requested_state != HERO_STATE_VEHICLE_MODE_3_DYING && @@ -135,7 +136,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { switch (requested_state) { case HERO_STATE_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; p->unk1010 = random_int_between(scale_game_frames(0x32), scale_game_frames(0x64)); clear_hero_idle_rotation_targets(); @@ -164,7 +165,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_AT_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; clear_u64_value(&p->motion.momentum); p->rand_timer.range = 0x68; @@ -191,7 +192,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -200,7 +201,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DYING_SPEED_LIMITED: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -211,7 +212,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_SINK: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->unk694 = p->motion.displacement.f[2] * 0.2f; @@ -227,11 +228,11 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_SWIM: { struct Hero *p = &hero; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; *(int *)&p->drown_sink_speed = 0; - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } else { @@ -251,11 +252,11 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_SWIM_WITH_CROUCH_INPUT: { struct Hero *p = &hero; int n; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; p->unk8F4 = scale_game_frames(0x3C); - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } @@ -272,7 +273,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { struct Hero *p = &hero; int n; int t; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -287,11 +288,11 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_WATER_SURFACE_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; p->splash_effect_timer = 0; - if (p->state.prev_control_mode == 0x11) { + if (p->state.prev_control_mode == HERO_MODE_SWIM) { emit_hero_surface_effect_burst(3, 0xA, 0); if (D_L03_001612D0 != 0) { pool_splash(D_L03_001612D0, @@ -322,7 +323,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { { struct Hero *q = &hero; q->unk698 = 0; - if (q->state.prev_control_mode == 0x11) { + if (q->state.prev_control_mode == HERO_MODE_SWIM) { float d = (float)q->underwater_air; if (d < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); @@ -331,7 +332,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *r = &hero; - if (r->state.prev_control_mode == 0x11) { + if (r->state.prev_control_mode == HERO_MODE_SWIM) { float e = (float)r->underwater_air; if (e < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); @@ -363,7 +364,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->item_select_blocked = 1; @@ -396,7 +397,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_WATER_SURFACE_MOVE: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; *(int *)&p->drown_sink_speed = 0; @@ -408,7 +409,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DROWN: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -448,7 +449,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DYING_ZERO_HEALTH: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -460,7 +461,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_LOOK: { struct Hero *p = &hero; int t; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 4; *(int *)&D_L03_0015F688 = scale_game_frames(0x3C); if (p->unk20AA == 0) { @@ -473,7 +474,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ITEM_BUTTON_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(0xA)); @@ -482,7 +483,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_WAIT_FOR_ITEM_RELEASE_THEN_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(5)); @@ -491,7 +492,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ITEM_BUTTON_HOLD_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.displacement); p->state.step = 0; @@ -504,9 +505,10 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_DIRECTION_LIMITED_GROUND_MOVE: case HERO_STATE_SHALLOW_WATER_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; - if (p->state.prev_control_mode != 4 && p->state.prev2_control_mode != 4) { + if (p->state.prev_control_mode != HERO_MODE_JUMP && + p->state.prev2_control_mode != HERO_MODE_JUMP) { p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); } { @@ -517,7 +519,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { stick_target(1.0f, 0); if (1.5707964f < fast_difference_between_rotations(q->motion.rot.f[2], q->motion.move_yaw)) { - if (q->state.prev_control_mode == 7 || q->state.prev == 3 || q->state.prev2 == 3) { + if (q->state.prev_control_mode == HERO_MODE_HURT || q->state.prev == 3 || + q->state.prev2 == 3) { struct Hero *r = &hero; r->ground_speed = 0.0f; } @@ -550,7 +553,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { n = scale_game_frames(0x12); { struct Hero *u = &hero; - if (u->state.prev2_control_mode == 4 && + if (u->state.prev2_control_mode == HERO_MODE_JUMP && scale_game_frames(5) < u->rail_land_frames) n = scale_game_frames(0xD); } @@ -564,7 +567,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_APPROACH_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->item_use_locked = 1; @@ -595,7 +598,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_STOP: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (p->on_slip_ground != 0 && p->frames_off_ground.s == 0) { @@ -624,7 +627,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_BRAKE_AT_TARGET_POSITION: { struct Hero *p = &hero; char *v = (char *)&p->motion.resolved_velocity; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = gravity_length_xy((float *)v); qcopy(&p->motion.momentum, v); @@ -639,7 +642,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_CROUCH: { struct Hero *p = &hero; - p->state.control_mode = 0xC; + p->state.control_mode = HERO_MODE_CROUCH; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); if (frame_time * 7.0f < p->ground_speed) @@ -668,7 +671,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_GRAPPLE_TARGET_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -690,7 +693,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_APPROACH_TARGET_MOBY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; *(int *)&p->grapple_pull_speed = 0; p->grapple_pull_ending = 0; @@ -701,7 +704,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_CONSTRAIN_TO_TARGET_RADIUS: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; p->item_use_locked = 1; *(int *)&p->grapple_pull_speed = 0; @@ -714,7 +717,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_GRAPPLE_SWING_ENTRY: { struct Hero *p = &hero; char *d; - p->state.control_mode = 0xE; + p->state.control_mode = HERO_MODE_GRAPPLE_SWING; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -758,9 +761,9 @@ int hero_set_state(int requested_state, int entry_animation_mode) { q->swing_target_moby->pos.y - q->motion.pos.f[1]); q->unk9A4 = fast_vec_dist(&q->motion.pos, &q->swing_target_moby->pos); q->swing_gravity = frame_time_sq * 27.0f; - if (q->state.prev_control_mode == 4) { + if (q->state.prev_control_mode == HERO_MODE_JUMP) { q->swing_gravity = q->jump_gravity; - } else if (q->state.prev_control_mode == 2) { + } else if (q->state.prev_control_mode == HERO_MODE_FALL) { q->swing_gravity = q->fall_state_gravity; } if (entry_animation_mode) { @@ -775,7 +778,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ITEM_RELEASE_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 7; clear_u64_value(&p->motion.rot_spring_vel); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -801,7 +804,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { float pos[4]; int seg; float t; - p->state.control_mode = 0x1A; + p->state.control_mode = HERO_MODE_FOLLOW_PATH; p->unk2284 = 3; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -823,11 +826,11 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 24.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -843,7 +846,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -853,7 +856,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_SHIMMY_POSITIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (entry_animation_mode) @@ -862,7 +865,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_SHIMMY_NEGATIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (entry_animation_mode) @@ -871,7 +874,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -881,7 +884,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_FALL: case HERO_STATE_FATAL_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -916,7 +919,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_DELAYED_JUMP_OR_R1_REPEAT_EXIT_WAIT: { struct Hero *p = &hero; int animation_timing_value = -2; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk22CA = 1; p->rand_timer.range = 0x68; p->unk2284 = 0; @@ -932,7 +935,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_LAND: { struct Hero *p = &hero; int animation_timing = -2; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->rand_timer.range = 0x68; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { @@ -970,7 +973,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { p->state_timer = p->state.prev_timer; return 0; } - p->state.control_mode = 4; + p->state.control_mode = HERO_MODE_JUMP; if (requested_state >= HERO_STATE_GRIND_JUMP && requested_state <= HERO_STATE_GRIND_RAIL_TRANSFER) { p->unk2284 = 3; @@ -1263,7 +1266,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } else if (s == 0xA) { set_hero_animation(0x12, 0, (float)scale_game_frames(5)); } else if (s == 0x10) { - if (q->state.prev_control_mode == 4 || + if (q->state.prev_control_mode == HERO_MODE_JUMP || (q->state.prev == 4 && scale_game_frames(7) > q->state_timer)) { set_hero_animation(0x26, 0, (float)scale_game_frames(8)); q->takeoff_frame += scale_game_frames(3); @@ -1295,7 +1298,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *w = &hero; - if (w->state.prev_control_mode == 4) { + if (w->state.prev_control_mode == HERO_MODE_JUMP) { set_hero_animation(id, 1, (float)scale_game_frames(4)); w->takeoff_frame = scale_game_frames(1); } else { @@ -1314,7 +1317,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_ANIMATION_RECOVERY_WITH_JUMP_CANCEL: case HERO_STATE_VEHICLE_MODE_1_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->speed_scale = 1.0f; p->unk2284 = 0; p->heading_locked = 0; @@ -1413,7 +1416,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { e = &D_L03_0017BD28[q->attack_record]; q->saved_item[0] = 0; k = 0; - if (q->state.prev_control_mode == 6 && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { + if (q->state.prev_control_mode == HERO_MODE_ATTACK && e->unk0 == 0 && + q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 3; } { @@ -1499,7 +1503,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_HURT: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->unk1EE = scale_game_frames(0x2D); @@ -1524,7 +1528,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (entry_animation_mode) set_hero_animation(0, 0, (float)scale_game_frames(0xE)); @@ -1532,7 +1536,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DELAYED_CIRCLE_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (entry_animation_mode) { set_hero_animation(4, 0, (float)scale_game_frames(7)); @@ -1542,7 +1546,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -1551,7 +1555,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1562,7 +1566,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; { char *v = (char *)&p->motion.resolved_velocity; @@ -1580,7 +1584,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -1589,7 +1593,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1605,7 +1609,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_GRIND_COLLISION_RECOVERY: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 0; if (p->rail_off_frames == 0) hero_change_health(1); @@ -1632,7 +1636,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_LOOK_RELEASE_WAIT: { struct Hero *p = &hero; p->unk2284 = 0x51; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; if (return_hero_animation_id_unchanged(p->moby->prev_seq) != get_hero_idle_animation_index(1)) { set_hero_animation(get_hero_idle_animation_index(1), 0, (float)scale_game_frames(5)); @@ -1657,7 +1661,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_IDLE_ANIMATION_LONG_BLEND_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(0xA)); break; @@ -1723,7 +1727,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode != 0xF && t->items[1].item_id == 0x1D && t->saved_item[1] != 0) { + if (t->state.control_mode != HERO_MODE_GRIND && t->items[1].item_id == 0x1D && + t->saved_item[1] != 0) { t->restore_item[1] = 1; } } @@ -1735,7 +1740,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode == 0x14) { + if (t->state.control_mode == HERO_MODE_DYING) { cancel_hero_item_animation(); t->item_use_locked = 1; } diff --git a/src/overlays/l03/hero/update_hero_motion_for_current_state.c b/src/overlays/l03/hero/update_hero_motion_for_current_state.c index 8ac3e2d2ae..204195c503 100644 --- a/src/overlays/l03/hero/update_hero_motion_for_current_state.c +++ b/src/overlays/l03/hero/update_hero_motion_for_current_state.c @@ -1746,12 +1746,12 @@ void update_hero_motion_for_current_state(void) { f32 f; f32 old; f32 d; - if (current_level_index == 0xF) { + if (current_level_index == LEVEL_QUARTU) { release_voice_slot_cf(2, MV(hero.moby), 0x1D); } else { release_voice_slot_cf(2, MV(hero.moby), 6); } - if (current_level_index != 0xF) { + if (current_level_index != LEVEL_QUARTU) { emit_hero_randomized_motion_effects(4, 2); spatial_scratch_or_hit_descriptor.f[0] = hero.motion.pos.f[0] + random_float_between(-0.25f, 0.25f); diff --git a/src/overlays/l03/hero/update_hero_state_machine.c b/src/overlays/l03/hero/update_hero_state_machine.c index d1620fa07d..5a3d764efb 100644 --- a/src/overlays/l03/hero/update_hero_state_machine.c +++ b/src/overlays/l03/hero/update_hero_state_machine.c @@ -160,7 +160,7 @@ void update_hero_state_machine(void) { prevState = hero.state.step; prevAnim = MOBY(moby)->prev_seq; if (process_hero_hit_response(1) == 0) { - if (hero.health.hp <= 0 && hero.state.control_mode != 0x14 && + if (hero.health.hp <= 0 && hero.state.control_mode != HERO_MODE_DYING && (hero.state.current == HERO_STATE_IDLE || hero.state.current == HERO_STATE_RUN)) { hero_set_state(HERO_STATE_DYING, 1); } else if (process_hero_equipped_item_input() == 0 && try_enter_hero_water_state() == 0 && @@ -415,7 +415,7 @@ void update_hero_state_machine(void) { } } if (ok && 0.22f < hero.stick_magnitude) { - if (current_level_index == 0xC) { + if (current_level_index == LEVEL_HOVEN) { int slot = hero.ground_sound_class; request_hero_voice_if_enabled(slot, 0, 0); request_hero_voice_if_enabled(slot, 1, 0); @@ -606,7 +606,8 @@ void update_hero_state_machine(void) { break; case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: if (hero.health.hp <= 0) { - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || + current_level_index == LEVEL_VELDIN_ORBIT) { hero_set_state(0x82, 1); break; } @@ -784,7 +785,8 @@ void update_hero_state_machine(void) { break; } if (!(hero.air_frames.s < scale_game_frames(5)) && - !(hero.state.prev_control_mode == 0x12 && hero.wading != 0) && + !(hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE && + hero.wading != 0) && hero.ground_distance > 1.35f) { if (check_hero_forward_collision_height() == 0) { hero_set_state(HERO_STATE_FALL, 1); @@ -844,7 +846,8 @@ void update_hero_state_machine(void) { } } if (hero.state_timer > scale_game_frames(0xF) || - (hero.state.prev_control_mode != 0 && hero.state.prev_control_mode != 1)) { + (hero.state.prev_control_mode != HERO_MODE_IDLE && + hero.state.prev_control_mode != HERO_MODE_RUN)) { if ((controller_state.pressed & 0x10000) && hero.unk20AA == 0) { hero.unk3BE = 1; } @@ -1394,9 +1397,9 @@ void update_hero_state_machine(void) { } break; case HERO_STATE_FATAL_FALL: - if ((current_level_index == 3 && 5.0f > hero.motion.pos.f[2]) || - (current_level_index == 6 && 50.0f > hero.motion.pos.f[2]) || - (current_level_index == 0x10 && + if ((current_level_index == LEVEL_KERWAN && 5.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_NEBULA_G34 && 50.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_KALEBO3 && (77.0f > hero.motion.pos.f[2] || (hero.state_timer > 0x14 && hero.wall_hit != 0 && hero.motion.displacement.f[2] >= 0.0f))) || diff --git a/src/overlays/l03/mobys/help_hints.c b/src/overlays/l03/mobys/help_hints.c index 717ba051f0..7fa76cfe43 100644 --- a/src/overlays/l03/mobys/help_hints.c +++ b/src/overlays/l03/mobys/help_hints.c @@ -209,7 +209,7 @@ void help_hints_update(struct Moby *moby) { usage_stats.stat[16].level_mask | (1 << current_level_index) | 0x80000000; } if (is_point_inside_clip_volume(&hero.motion.pos, tutorial_hint_state[11]) && - usage_stats.stat[16].count == 0 && hero.state.control_mode == 6 && + usage_stats.stat[16].count == 0 && hero.state.control_mode == HERO_MODE_ATTACK && hero.items[0].item_id == 8 && l03_help_message_playback_state.state == HELP_PLAYBACK_IDLE && l03_help_message_playback_state.cur == -1 && help_records[0x1B].count == 0) { diff --git a/src/overlays/l03/mobys/metropolis_train_locomotive.c b/src/overlays/l03/mobys/metropolis_train_locomotive.c index d3e0741c7c..7526de1ae6 100644 --- a/src/overlays/l03/mobys/metropolis_train_locomotive.c +++ b/src/overlays/l03/mobys/metropolis_train_locomotive.c @@ -551,7 +551,7 @@ void metropolis_train_locomotive_update(char *moby) { D_L03_0015FDFC = 1; update_metropolis_train_motion(moby); ENGINE_SOUND(); - if (hero.air_frames.s != 0 && hero.state.control_mode != 3) { + if (hero.air_frames.s != 0 && hero.state.control_mode != HERO_MODE_LEDGE) { FUN_L00_0025df68( cdata->path, hero.motion.pos.f, start, &seg, &frac, 0, 999.0f, 5.0f, 0.0f); train_engine_pvars->fall_check_airborne_frames += 1; diff --git a/src/overlays/l03/render_sky_shells.c b/src/overlays/l03/render_sky_shells.c index 55847f6b87..3be1b7ffbb 100644 --- a/src/overlays/l03/render_sky_shells.c +++ b/src/overlays/l03/render_sky_shells.c @@ -11,7 +11,7 @@ void render_sky_shells(void) __asm__("FUN_L03_0022c6a8"); void render_sky_shells(void) { setup_sky_gif_paging(); - if (current_level_index == 0x3) { + if (current_level_index == LEVEL_KERWAN) { sky_shells_rotate_two(); } else { update_sky_shells_static(); diff --git a/src/overlays/l04/draw_sky_shells_with_gif_paging.c b/src/overlays/l04/draw_sky_shells_with_gif_paging.c index c90d0c7f68..578b203f8a 100644 --- a/src/overlays/l04/draw_sky_shells_with_gif_paging.c +++ b/src/overlays/l04/draw_sky_shells_with_gif_paging.c @@ -11,7 +11,7 @@ void draw_sky_shells_with_gif_paging(void) __asm__("FUN_L04_00230f48"); void draw_sky_shells_with_gif_paging(void) { setup_sky_gif_paging(); - if (current_level_index == 0x4) { + if (current_level_index == LEVEL_EUDORA) { draw_sky_shells_with_fast_and_slow_rotation(); } else { update_sky_shells_static(); diff --git a/src/overlays/l04/mobys/platform_booster.c b/src/overlays/l04/mobys/platform_booster.c index 50c08bd12b..6c22a461f7 100644 --- a/src/overlays/l04/mobys/platform_booster.c +++ b/src/overlays/l04/mobys/platform_booster.c @@ -76,7 +76,7 @@ void platform_booster_update(struct Moby *moby) { } else if (lv->travel != 1.0f || (door_vars->target != -1 && door_vars->locked == 0 && ((u32)hero.state.control_mode < 2 || hero.state.control_mode == 9 || - hero.state.control_mode == 12) && + hero.state.control_mode == HERO_MODE_CROUCH) && hero.ground_moby == &((struct Moby *)moby_array)[door_vars->target])) { moby->state = PLATFORM_BOOSTER_STATE_ADVANCE_ANIMATION; } diff --git a/src/overlays/l05/hero/apply_hero_ground_material_effects.c b/src/overlays/l05/hero/apply_hero_ground_material_effects.c index 58564cc06a..cd68da8b22 100644 --- a/src/overlays/l05/hero/apply_hero_ground_material_effects.c +++ b/src/overlays/l05/hero/apply_hero_ground_material_effects.c @@ -67,7 +67,7 @@ void apply_hero_ground_material_effects(void) { } if (saved_ground_type == GROUND_MATERIAL_SINK_SURFACE_PROBE_THROUGH) hero.selector_3 = 1; - if (current_level_index == 13 && hero.state.current != 0x7B && + if (current_level_index == LEVEL_OLTANIS_ORBIT && hero.state.current != 0x7B && FUN_L00_001f0d60_239fc0( (u8 *)&hero.motion.body_center, 2, 0, hero.capsule_radius + 0.03f) && collision_hit_material() == 11) { @@ -92,7 +92,7 @@ void apply_hero_ground_material_effects(void) { if (saved_ground_type == 12) hero.on_slip_ground = 1; if (hero.selector_4 && hero.grounded_frames && hero.state.control_mode != 0x10 && - hero.state.control_mode != 0x14 && hero.state.control_mode != 7) { + hero.state.control_mode != HERO_MODE_DYING && hero.state.control_mode != HERO_MODE_HURT) { s = 0x31; goto call; } @@ -208,7 +208,7 @@ void update_hero_ground_contact(void) { if (hero.gravity_mode) k = 1; ground_probe_endpoint_offset = hero.capsule_radius * 2.2f; - if (hero.state.control_mode == 2) { + if (hero.state.control_mode == HERO_MODE_FALL) { ground_probe_endpoint_offset = hero.capsule_radius * 2.9f; } hero_get_collision_ray_endpoints( @@ -233,7 +233,7 @@ void update_hero_ground_contact(void) { goto d1; } ground_sound_class = coll_sound_class(); - if (current_level_index == 1 || current_level_index == 0x12) { + if (current_level_index == LEVEL_NOVALIS || current_level_index == LEVEL_VELDIN2) { ground_sound_class = 3; } hero.ground_sound_class = ground_sound_class; @@ -330,9 +330,9 @@ void update_hero_ground_contact(void) { hero.unk2C8.i[1] = 0; hero.unk2C0.i[0] = 0; hero.unk2C0.i[1] = 0; - if (hero.state.control_mode == 0xF || hero.state.control_mode == 0x15 || - hero.state.control_mode == 6 || hero.state.control_mode == 4 || - hero.state.control_mode == 5 || hero.state.control_mode == 3) { + if (hero.state.control_mode == HERO_MODE_GRIND || hero.state.control_mode == 0x15 || + hero.state.control_mode == HERO_MODE_ATTACK || hero.state.control_mode == HERO_MODE_JUMP || + hero.state.control_mode == HERO_MODE_LAND || hero.state.control_mode == HERO_MODE_LEDGE) { return; } if (!(hero.ground_distance < 0.25f)) { @@ -412,7 +412,7 @@ s32 resolve_hero_position_collisions(s32 mode) { resolve_hero_pending_path_clearance(); hero.path_constrain_pending = 0; } - if (hero.state.control_mode != 0x11) { + if (hero.state.control_mode != HERO_MODE_SWIM) { if (hero.state.control_mode == 0x16) { transform_hero_local_offset_to_world(&collision_query_offset, 0.0f, 0.0f, 0.7f); fast_vec_sub(&collision_query_offset, &collision_query_offset, &hero.motion.pos.q); @@ -437,7 +437,7 @@ s32 resolve_hero_position_collisions(s32 mode) { if (hero.gravity_mode != HERO_GRAVITY_WORLD_DOWN) { if (!coll_sphere(&hero.motion.pos.q, mask, ((s32)hero.moby), frame_scale * 0.4f)) break; - } else if (hero.state.control_mode == 0x11) { + } else if (hero.state.control_mode == HERO_MODE_SWIM) { if (!coll_sphere(&hero.motion.pos.q, mask, ((s32)hero.moby), 0.6f)) break; } else if (hero.state.control_mode == 0x16) { diff --git a/src/overlays/l05/hero/hero_set_state.c b/src/overlays/l05/hero/hero_set_state.c index dc66fb77a5..d53d1e3d92 100644 --- a/src/overlays/l05/hero/hero_set_state.c +++ b/src/overlays/l05/hero/hero_set_state.c @@ -87,7 +87,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { int old20A7; { struct Hero *p = &hero; - if (p->state.control_mode == 0x14 && + if (p->state.control_mode == HERO_MODE_DYING && (requested_state != HERO_STATE_IDLE_ANIMATION_WITH_DYING_OVERRIDE || animation_request_mode != HERO_ANIMATION_ENTRY_OVERRIDE_GUARDS)) return 0; @@ -97,7 +97,8 @@ int hero_set_state(int requested_state, int animation_request_mode) { return 0; { struct Hero *p = &hero; - if (p->health.hp == 0 && (p->state.control_mode == 2 || p->state.control_mode == 7) && + if (p->health.hp == 0 && + (p->state.control_mode == HERO_MODE_FALL || p->state.control_mode == HERO_MODE_HURT) && requested_state != HERO_STATE_FALL && requested_state != HERO_STATE_DYING && requested_state != HERO_STATE_VEHICLE_MODE_1_DYING && requested_state != HERO_STATE_VEHICLE_MODE_3_DYING && @@ -148,7 +149,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { switch (requested_state) { case HERO_STATE_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; p->unk1010 = random_int_between(scale_game_frames(0x32), scale_game_frames(0x64)); clear_hero_idle_rotation_targets(); @@ -177,7 +178,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_AT_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; clear_u64_value(&p->motion.momentum); p->rand_timer.range = 0x68; @@ -204,7 +205,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (animation_request_mode) @@ -213,7 +214,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_DYING_SPEED_LIMITED: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -224,7 +225,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_SINK: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->unk694 = p->motion.displacement.f[2] * 0.2f; @@ -240,11 +241,11 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_SWIM: { struct Hero *p = &hero; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; *(int *)&p->drown_sink_speed = 0; - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } else { @@ -264,11 +265,11 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_SWIM_WITH_CROUCH_INPUT: { struct Hero *p = &hero; int n; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; p->unk8F4 = scale_game_frames(0x3C); - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } @@ -285,7 +286,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { struct Hero *p = &hero; int n; int t; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -300,11 +301,11 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_WATER_SURFACE_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; p->splash_effect_timer = 0; - if (p->state.prev_control_mode == 0x11) { + if (p->state.prev_control_mode == HERO_MODE_SWIM) { emit_hero_surface_effect_burst(3, 0xA, 0); if (D_L05_001612D0 != 0) { pool_splash(D_L05_001612D0, @@ -335,7 +336,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { { struct Hero *q = &hero; q->unk698 = 0; - if (q->state.prev_control_mode == 0x11) { + if (q->state.prev_control_mode == HERO_MODE_SWIM) { float d = (float)q->underwater_air; if (d < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); @@ -344,7 +345,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } { struct Hero *r = &hero; - if (r->state.prev_control_mode == 0x11) { + if (r->state.prev_control_mode == HERO_MODE_SWIM) { float e = (float)r->underwater_air; if (e < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); @@ -376,7 +377,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->item_select_blocked = 1; @@ -409,7 +410,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_WATER_SURFACE_MOVE: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; *(int *)&p->drown_sink_speed = 0; @@ -421,7 +422,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_DROWN: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -461,7 +462,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_DYING_ZERO_HEALTH: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -500,7 +501,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { struct Hero *q = &hero; if (q->state.prev_control_mode != 0x16) { char *m; - if (current_level_index == 5) { + if (current_level_index == LEVEL_RILGAR) { q->motion.pos.f[0] = 247.0f; q->motion.pos.f[1] = 287.0f; q->motion.pos.f[2] = 76.0f; @@ -655,7 +656,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_LOOK: { struct Hero *p = &hero; int t; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 4; *(int *)&D_L05_0015F688 = scale_game_frames(0x3C); if (p->unk20AA == 0) { @@ -668,7 +669,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_ITEM_BUTTON_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(0xA)); @@ -677,7 +678,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_WAIT_FOR_ITEM_RELEASE_THEN_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(5)); @@ -686,7 +687,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_ITEM_BUTTON_HOLD_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.displacement); p->state.step = 0; @@ -699,9 +700,10 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_DIRECTION_LIMITED_GROUND_MOVE: case HERO_STATE_SHALLOW_WATER_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; - if (p->state.prev_control_mode != 4 && p->state.prev2_control_mode != 4) { + if (p->state.prev_control_mode != HERO_MODE_JUMP && + p->state.prev2_control_mode != HERO_MODE_JUMP) { p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); } { @@ -712,7 +714,8 @@ int hero_set_state(int requested_state, int animation_request_mode) { stick_target(1.0f, 0); if (1.5707964f < fast_difference_between_rotations(q->motion.rot.f[2], q->motion.move_yaw)) { - if (q->state.prev_control_mode == 7 || q->state.prev == 3 || q->state.prev2 == 3) { + if (q->state.prev_control_mode == HERO_MODE_HURT || q->state.prev == 3 || + q->state.prev2 == 3) { struct Hero *r = &hero; r->ground_speed = 0.0f; } @@ -745,7 +748,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { n = scale_game_frames(0x12); { struct Hero *u = &hero; - if (u->state.prev2_control_mode == 4 && + if (u->state.prev2_control_mode == HERO_MODE_JUMP && scale_game_frames(5) < u->rail_land_frames) n = scale_game_frames(0xD); } @@ -759,7 +762,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_APPROACH_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->item_use_locked = 1; @@ -790,7 +793,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_STOP: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (p->on_slip_ground != 0 && p->frames_off_ground.s == 0) { @@ -819,7 +822,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_BRAKE_AT_TARGET_POSITION: { struct Hero *p = &hero; char *v = (char *)&p->motion.resolved_velocity; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = gravity_length_xy((float *)v); qcopy(&p->motion.momentum, v); @@ -834,7 +837,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_CROUCH: { struct Hero *p = &hero; - p->state.control_mode = 0xC; + p->state.control_mode = HERO_MODE_CROUCH; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); if (frame_time * 7.0f < p->ground_speed) @@ -863,7 +866,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_GRAPPLE_TARGET_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -885,7 +888,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_APPROACH_TARGET_MOBY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; *(int *)&p->grapple_pull_speed = 0; p->grapple_pull_ending = 0; @@ -896,7 +899,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_CONSTRAIN_TO_TARGET_RADIUS: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; p->item_use_locked = 1; *(int *)&p->grapple_pull_speed = 0; @@ -909,7 +912,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_GRAPPLE_SWING_ENTRY: { struct Hero *p = &hero; char *d; - p->state.control_mode = 0xE; + p->state.control_mode = HERO_MODE_GRAPPLE_SWING; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -953,9 +956,9 @@ int hero_set_state(int requested_state, int animation_request_mode) { q->swing_target_moby->pos.y - q->motion.pos.f[1]); q->unk9A4 = fast_vec_dist(&q->motion.pos, &q->swing_target_moby->pos); q->swing_gravity = frame_time_sq * 27.0f; - if (q->state.prev_control_mode == 4) { + if (q->state.prev_control_mode == HERO_MODE_JUMP) { q->swing_gravity = q->jump_gravity; - } else if (q->state.prev_control_mode == 2) { + } else if (q->state.prev_control_mode == HERO_MODE_FALL) { q->swing_gravity = q->fall_state_gravity; } if (animation_request_mode) { @@ -970,7 +973,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_ITEM_RELEASE_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 7; clear_u64_value(&p->motion.rot_spring_vel); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -992,11 +995,11 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 24.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -1012,7 +1015,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -1022,7 +1025,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_LEDGE_SHIMMY_POSITIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (animation_request_mode) @@ -1031,7 +1034,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_LEDGE_SHIMMY_NEGATIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (animation_request_mode) @@ -1040,7 +1043,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (animation_request_mode) @@ -1050,7 +1053,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_FALL: case HERO_STATE_FATAL_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1085,7 +1088,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_DELAYED_JUMP_OR_R1_REPEAT_EXIT_WAIT: { struct Hero *p = &hero; int animation_timing_parameter = -2; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk22CA = 1; p->rand_timer.range = 0x68; p->unk2284 = 0; @@ -1101,7 +1104,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_LAND: { struct Hero *p = &hero; int animation_timing_setting = -2; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->rand_timer.range = 0x68; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { @@ -1139,7 +1142,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { p->state_timer = p->state.prev_timer; return 0; } - p->state.control_mode = 4; + p->state.control_mode = HERO_MODE_JUMP; if (requested_state >= HERO_STATE_GRIND_JUMP && requested_state <= HERO_STATE_GRIND_RAIL_TRANSFER) { p->unk2284 = 3; @@ -1242,11 +1245,11 @@ int hero_set_state(int requested_state, int animation_request_mode) { u->unk498 = scale_game_frames(2); u->jump_max_frames = scale_game_frames(0x78); hero_change_health(1); - if (current_level_index == 0xA) { + if (current_level_index == LEVEL_ORXON) { hero_set_state(0x7C, 1); return 0; } - if (current_level_index != 6) { + if (current_level_index != LEVEL_NEBULA_G34) { if (u->state.prev == 0x3C || u->state.prev2 == 0x3C || u->health.hp == 0) { struct Hero *w = &hero; w->sink_jump_count = w->sink_jump_count + 1; @@ -1267,7 +1270,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } } else if (u->state.current == 0x69) { float v; - u->state.control_mode = 0x19; + u->state.control_mode = HERO_MODE_RESPAWN_WAIT; if (u->motion.pos.f[2] < u->sink_surface_z) { v = u->sink_surface_z - u->motion.pos.f[2]; } else { @@ -1493,7 +1496,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } else if (s == 0xA) { set_hero_animation(0x12, 0, (float)scale_game_frames(5)); } else if (s == 0x10) { - if (q->state.prev_control_mode == 4 || + if (q->state.prev_control_mode == HERO_MODE_JUMP || (q->state.prev == 4 && scale_game_frames(7) > q->state_timer)) { set_hero_animation(0x26, 0, (float)scale_game_frames(8)); q->takeoff_frame += scale_game_frames(3); @@ -1525,7 +1528,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } { struct Hero *w = &hero; - if (w->state.prev_control_mode == 4) { + if (w->state.prev_control_mode == HERO_MODE_JUMP) { set_hero_animation(id, 1, (float)scale_game_frames(4)); w->takeoff_frame = scale_game_frames(1); } else { @@ -1544,7 +1547,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_ANIMATION_RECOVERY_WITH_JUMP_CANCEL: case HERO_STATE_VEHICLE_MODE_1_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->speed_scale = 1.0f; p->unk2284 = 0; p->heading_locked = 0; @@ -1643,7 +1646,8 @@ int hero_set_state(int requested_state, int animation_request_mode) { e = &D_L05_0017C088[q->attack_record]; q->saved_item[0] = 0; k = 0; - if (q->state.prev_control_mode == 6 && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { + if (q->state.prev_control_mode == HERO_MODE_ATTACK && e->unk0 == 0 && + q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 3; } { @@ -1729,7 +1733,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_HURT: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->unk1EE = scale_game_frames(0x2D); @@ -1755,7 +1759,8 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_WAIT_FOR_JUMP_OR_RESPAWN: { struct Hero *p = &hero; if (p->state.prev == 0x69 || - (p->state.prev2 == 0x69 && p->state.prev_control_mode != 0 && p->state.prev != 7)) { + (p->state.prev2 == 0x69 && p->state.prev_control_mode != HERO_MODE_IDLE && + p->state.prev != 7)) { p->sink_jump_count = p->sink_jump_count + 1; } else { struct Hero *q = &hero; @@ -1763,7 +1768,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } { struct Hero *r = &hero; - r->state.control_mode = 0x19; + r->state.control_mode = HERO_MODE_RESPAWN_WAIT; r->unk2284 = 0; allocate_hero_voice_for_entry(9, 0); r->rand_timer.range = 0x68; @@ -1776,9 +1781,9 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_HEIGHT_OR_TIMEOUT_RESPAWN_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0x19; + p->state.control_mode = HERO_MODE_RESPAWN_WAIT; p->unk2284 = 0; - if (current_level_index == 0xF) + if (current_level_index == LEVEL_QUARTU) spawn_hero_radial_particle_burst(); p->collision_off_frames = 0x2710; allocate_hero_voice_for_entry(9, 0); @@ -1788,7 +1793,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { break; } case HERO_STATE_DEATH_DESCENT: { - if (current_level_index == 6) { + if (current_level_index == LEVEL_NEBULA_G34) { int c0; int c1; int c2; @@ -1803,7 +1808,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->collision_off_frames = 0x2710; @@ -1816,7 +1821,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_VEHICLE_MODE_3_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (animation_request_mode) set_hero_animation(0, 0, (float)scale_game_frames(0xE)); @@ -1824,7 +1829,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_DELAYED_CIRCLE_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (animation_request_mode) { set_hero_animation(4, 0, (float)scale_game_frames(7)); @@ -1834,7 +1839,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_VEHICLE_MODE_3_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (animation_request_mode) @@ -1843,7 +1848,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_VEHICLE_MODE_3_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1854,7 +1859,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_VEHICLE_MODE_3_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; { char *v = (char *)&p->motion.resolved_velocity; @@ -1872,7 +1877,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_VEHICLE_MODE_3_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (animation_request_mode) @@ -1881,7 +1886,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_VEHICLE_MODE_3_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1897,7 +1902,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_GRIND_COLLISION_RECOVERY: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 0; if (p->rail_off_frames == 0) hero_change_health(1); @@ -1924,7 +1929,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_LOOK_RELEASE_WAIT: { struct Hero *p = &hero; p->unk2284 = 0x51; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; if (return_hero_animation_id_unchanged(p->moby->prev_seq) != get_hero_idle_animation_index(1)) { set_hero_animation(get_hero_idle_animation_index(1), 0, (float)scale_game_frames(5)); @@ -1949,7 +1954,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_IDLE_ANIMATION_LONG_BLEND_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(0xA)); break; @@ -2001,7 +2006,8 @@ int hero_set_state(int requested_state, int animation_request_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode != 0xF && t->items[1].item_id == 0x1D && t->saved_item[1] != 0) { + if (t->state.control_mode != HERO_MODE_GRIND && t->items[1].item_id == 0x1D && + t->saved_item[1] != 0) { t->restore_item[1] = 1; } } @@ -2013,7 +2019,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode == 0x14) { + if (t->state.control_mode == HERO_MODE_DYING) { cancel_hero_item_animation(); t->item_use_locked = 1; } diff --git a/src/overlays/l05/hero/update_hero_motion_by_state.c b/src/overlays/l05/hero/update_hero_motion_by_state.c index 9b0828fcca..bdc9a9673a 100644 --- a/src/overlays/l05/hero/update_hero_motion_by_state.c +++ b/src/overlays/l05/hero/update_hero_motion_by_state.c @@ -2029,12 +2029,12 @@ void update_hero_motion_by_state(void) { f32 f; f32 old; f32 d; - if (current_level_index == 0xF) { + if (current_level_index == LEVEL_QUARTU) { release_voice_slot_cf(2, (struct MobyView *)hero.moby, 0x1D); } else { release_voice_slot_cf(2, (struct MobyView *)hero.moby, 6); } - if (current_level_index != 0xF) { + if (current_level_index != LEVEL_QUARTU) { emit_hero_randomized_motion_effects(4, 2); vector_and_hit_scratch.f[0] = hero.motion.pos.f[0] + random_float_between(-0.25f, 0.25f); diff --git a/src/overlays/l05/hero/update_hero_state_machine.c b/src/overlays/l05/hero/update_hero_state_machine.c index bdfefb1bd9..e86e0bd346 100644 --- a/src/overlays/l05/hero/update_hero_state_machine.c +++ b/src/overlays/l05/hero/update_hero_state_machine.c @@ -164,7 +164,7 @@ void update_hero_state_machine(void) { prevState = hero.state.step; prevAnim = MOBY(moby)->prev_seq; if (process_hero_hit_response(1) == 0) { - if (hero.health.hp <= 0 && hero.state.control_mode != 0x14 && + if (hero.health.hp <= 0 && hero.state.control_mode != HERO_MODE_DYING && (hero.state.current == HERO_STATE_IDLE || hero.state.current == HERO_STATE_RUN)) { hero_set_state(HERO_STATE_DYING, 1); } else if (process_hero_primary_item_input() == 0 && @@ -422,7 +422,7 @@ void update_hero_state_machine(void) { } } if (ok && 0.22f < hero.stick_magnitude) { - if (current_level_index == 0xC) { + if (current_level_index == LEVEL_HOVEN) { int slot = hero.ground_sound_class; request_hero_voice_if_enabled(slot, 0, 0); request_hero_voice_if_enabled(slot, 1, 0); @@ -613,7 +613,8 @@ void update_hero_state_machine(void) { break; case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: if (hero.health.hp <= 0) { - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || + current_level_index == LEVEL_VELDIN_ORBIT) { hero_set_state(0x82, 1); break; } @@ -802,7 +803,8 @@ void update_hero_state_machine(void) { break; } if (!(hero.air_frames.s < scale_game_frames(5)) && - !(hero.state.prev_control_mode == 0x12 && hero.wading != 0) && + !(hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE && + hero.wading != 0) && hero.ground_distance > 1.35f) { if (check_hero_forward_collision_height() == 0) { hero_set_state(HERO_STATE_FALL, 1); @@ -862,7 +864,8 @@ void update_hero_state_machine(void) { } } if (hero.state_timer > scale_game_frames(0xF) || - (hero.state.prev_control_mode != 0 && hero.state.prev_control_mode != 1)) { + (hero.state.prev_control_mode != HERO_MODE_IDLE && + hero.state.prev_control_mode != HERO_MODE_RUN)) { if ((controller_state.pressed & 0x10000) && hero.unk20AA == 0) { hero.unk3BE = 1; } @@ -1426,9 +1429,9 @@ void update_hero_state_machine(void) { } break; case HERO_STATE_FATAL_FALL: - if ((current_level_index == 3 && 5.0f > hero.motion.pos.f[2]) || - (current_level_index == 6 && 50.0f > hero.motion.pos.f[2]) || - (current_level_index == 0x10 && + if ((current_level_index == LEVEL_KERWAN && 5.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_NEBULA_G34 && 50.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_KALEBO3 && (77.0f > hero.motion.pos.f[2] || (hero.state_timer > 0x14 && hero.wall_hit != 0 && hero.motion.displacement.f[2] >= 0.0f))) || @@ -2121,7 +2124,7 @@ void update_hero_state_machine(void) { update_hero_hoverboard_trick_score(); break; case HERO_STATE_HOVERBOARD_RESPAWN_HEIGHT_OR_ANIMATION_WAIT: - if (current_level_index == 5 && 61.4f > hero.motion.pos.f[2]) { + if (current_level_index == LEVEL_RILGAR && 61.4f > hero.motion.pos.f[2]) { hero.board_floor_z = 61.4f; hero_set_state(0x6E, 1); hero.board_respawn_delay = scale_game_frames(0x46) - hero.state_timer; @@ -2130,7 +2133,7 @@ void update_hero_state_machine(void) { } return; } - if (current_level_index == 0x10 && 76.0f > hero.motion.pos.f[2]) { + if (current_level_index == LEVEL_KALEBO3 && 76.0f > hero.motion.pos.f[2]) { hero.board_floor_z = 76.0f; hero_set_state(0x6E, 1); hero.board_respawn_delay = scale_game_frames(0x46) - hero.state_timer; diff --git a/src/overlays/l05/mobys/help_hints.c b/src/overlays/l05/mobys/help_hints.c index cf5da87359..5a8fade9f7 100644 --- a/src/overlays/l05/mobys/help_hints.c +++ b/src/overlays/l05/mobys/help_hints.c @@ -193,7 +193,7 @@ void help_hints_update(struct Moby *moby) { D_00141C5A = scale_game_frames(gameplay_event_frame_count) / 600; D_00141C5C = D_00141C5C | (1 << gameplay_event_level_index) | 0x80000000; } - if (hero.state.control_mode == 0x12) { + if (hero.state.control_mode == HERO_MODE_WATER_SURFACE) { if (is_point_inside_clip_volume(gameplay_event_pvars + 4, gameplay_event_pvars[13]) || is_point_inside_clip_volume(gameplay_event_pvars + 4, gameplay_event_pvars[14])) { clear_u64_value(gameplay_event_pvars + 4); diff --git a/src/overlays/l05/mobys/sharkigator.c b/src/overlays/l05/mobys/sharkigator.c index 50fb823f48..1b4c085e72 100644 --- a/src/overlays/l05/mobys/sharkigator.c +++ b/src/overlays/l05/mobys/sharkigator.c @@ -139,7 +139,7 @@ state_one: { *(int *)l05_paths[sharkigator_instance_vars->path_60]; sharkigator_instance_vars->timer_6C = scale_game_frames(600); } - if ((hero.state.control_mode == 0x12 || hero.state.current == 0x12) && + if ((hero.state.control_mode == HERO_MODE_WATER_SURFACE || hero.state.current == 0x12) && vector_distance_xy(moby + 0x10, &hero.motion.pos) < 8.0f) { speed = (D_L05_001612E0_macro[2] - l05_sharkigator_position_offset_distance) - 2.0f; } else { @@ -158,7 +158,7 @@ state_two: { char *path; fast_dec_timer(&sharkigator_instance_vars->timer_7C); height = absolute_float(hero.water_surface_z - sharkigator_instance_vars->unk74); - if (height < 0.33f && hero.state.control_mode == 0x12) { + if (height < 0.33f && hero.state.control_mode == HERO_MODE_WATER_SURFACE) { char *point; if (sharkigator_instance_vars->timer_7C != 0) return; diff --git a/src/overlays/l05/mobys/water.c b/src/overlays/l05/mobys/water.c index 9bedef440e..e49f54ae30 100644 --- a/src/overlays/l05/mobys/water.c +++ b/src/overlays/l05/mobys/water.c @@ -278,7 +278,7 @@ void water_update(struct Moby *moby) { if (vector_distance_xy(((float *)&moby->pos), hero.motion.pos.f) < 16.0f) { Hero *h = &hero; if (h->motion.pos.f[2] < moby->pos.z) { - if (h->state.control_mode == 0x11) { + if (h->state.control_mode == HERO_MODE_SWIM) { if (h->water_surface_z < moby->pos.z) { h->water_surface_z = moby->pos.z; } diff --git a/src/overlays/l05/render_sky_shells.c b/src/overlays/l05/render_sky_shells.c index bee29a5cfd..32ae8091d3 100644 --- a/src/overlays/l05/render_sky_shells.c +++ b/src/overlays/l05/render_sky_shells.c @@ -11,7 +11,7 @@ void render_sky_shells(void) __asm__("FUN_L05_00267520"); void render_sky_shells(void) { setup_sky_gif_paging(); - if (current_level_index == 0x5) { + if (current_level_index == LEVEL_RILGAR) { draw_sky_shells_with_particles_and_modulo_50000_rotation(); } else { update_sky_shells_static(); diff --git a/src/overlays/l06/hero/hero_set_state.c b/src/overlays/l06/hero/hero_set_state.c index e3b43d2461..db2c688a0e 100644 --- a/src/overlays/l06/hero/hero_set_state.c +++ b/src/overlays/l06/hero/hero_set_state.c @@ -79,7 +79,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } d; { struct Hero *p = &hero; - if (p->state.control_mode == 0x14 && + if (p->state.control_mode == HERO_MODE_DYING && (requested_state != HERO_STATE_IDLE_ANIMATION_WITH_DYING_OVERRIDE || entry_animation_mode != HERO_ANIMATION_ENTRY_OVERRIDE_GUARDS)) return 0; @@ -89,7 +89,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { return 0; { struct Hero *p = &hero; - if (p->health.hp == 0 && (p->state.control_mode == 2 || p->state.control_mode == 7) && + if (p->health.hp == 0 && + (p->state.control_mode == HERO_MODE_FALL || p->state.control_mode == HERO_MODE_HURT) && requested_state != HERO_STATE_FALL && requested_state != HERO_STATE_DYING && requested_state != HERO_STATE_VEHICLE_MODE_1_DYING && requested_state != HERO_STATE_VEHICLE_MODE_3_DYING && @@ -140,7 +141,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { switch (requested_state) { case HERO_STATE_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; p->unk1010 = random_int_between(scale_game_frames(0x32), scale_game_frames(0x64)); clear_hero_idle_rotation_targets(); @@ -168,7 +169,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_AT_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; clear_u64_value(&p->motion.momentum); p->rand_timer.range = 0x68; @@ -194,7 +195,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -203,7 +204,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DYING_SPEED_LIMITED: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -214,7 +215,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_SINK: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->unk694 = p->motion.displacement.f[2] * 0.2f; @@ -231,7 +232,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_LOOK: { struct Hero *p = &hero; int t; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 4; *(int *)&D_L06_0015F688 = scale_game_frames(0x3C); if (p->unk20AA == 0) { @@ -244,7 +245,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ITEM_BUTTON_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_help_value(0), 0, (float)scale_game_frames(0xA)); @@ -253,7 +254,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_WAIT_FOR_ITEM_RELEASE_THEN_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_help_value(0), 0, (float)scale_game_frames(5)); @@ -262,7 +263,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ITEM_BUTTON_HOLD_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.displacement); p->state.step = 0; @@ -275,9 +276,10 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_DIRECTION_LIMITED_GROUND_MOVE: case HERO_STATE_SHALLOW_WATER_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; - if (p->state.prev_control_mode != 4 && p->state.prev2_control_mode != 4) { + if (p->state.prev_control_mode != HERO_MODE_JUMP && + p->state.prev2_control_mode != HERO_MODE_JUMP) { p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); } { @@ -288,7 +290,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { stick_target(1.0f, 0); if (1.5707964f < fast_difference_between_rotations(q->motion.rot.f[2], q->motion.move_yaw)) { - if (q->state.prev_control_mode == 7 || q->state.prev == 3 || q->state.prev2 == 3) { + if (q->state.prev_control_mode == HERO_MODE_HURT || q->state.prev == 3 || + q->state.prev2 == 3) { struct Hero *r = &hero; r->ground_speed = 0.0f; } @@ -317,7 +320,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { n = scale_game_frames(0x12); { struct Hero *u = &hero; - if (u->state.prev2_control_mode == 4 && scale_game_frames(5) < u->rail_land_frames) + if (u->state.prev2_control_mode == HERO_MODE_JUMP && + scale_game_frames(5) < u->rail_land_frames) n = scale_game_frames(0xD); } if (entry_animation_mode) { @@ -329,7 +333,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_APPROACH_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->item_use_locked = 1; @@ -349,7 +353,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_STOP: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (p->on_slip_ground != 0 && p->frames_off_ground.s == 0) { @@ -377,7 +381,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_BRAKE_AT_TARGET_POSITION: { struct Hero *p = &hero; char *v = (char *)&p->motion.resolved_velocity; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = gravity_length_xy((float *)v); qcopy(&p->motion.momentum, v); @@ -392,7 +396,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_CROUCH: { struct Hero *p = &hero; - p->state.control_mode = 0xC; + p->state.control_mode = HERO_MODE_CROUCH; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); if (frame_time * 7.0f < p->ground_speed) @@ -421,7 +425,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_GRAPPLE_TARGET_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -443,7 +447,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_APPROACH_TARGET_MOBY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; *(int *)&p->grapple_pull_speed = 0; p->grapple_pull_ending = 0; @@ -454,7 +458,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_CONSTRAIN_TO_TARGET_RADIUS: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; p->item_use_locked = 1; *(int *)&p->grapple_pull_speed = 0; @@ -467,7 +471,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_GRAPPLE_SWING_ENTRY: { struct Hero *p = &hero; char *d; - p->state.control_mode = 0xE; + p->state.control_mode = HERO_MODE_GRAPPLE_SWING; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -511,9 +515,9 @@ int hero_set_state(int requested_state, int entry_animation_mode) { q->swing_target_moby->pos.y - q->motion.pos.f[1]); q->unk9A4 = fast_vec_dist(&q->motion.pos, &q->swing_target_moby->pos); q->swing_gravity = frame_time_sq * 27.0f; - if (q->state.prev_control_mode == 4) { + if (q->state.prev_control_mode == HERO_MODE_JUMP) { q->swing_gravity = q->jump_gravity; - } else if (q->state.prev_control_mode == 2) { + } else if (q->state.prev_control_mode == HERO_MODE_FALL) { q->swing_gravity = q->fall_state_gravity; } if (entry_animation_mode) { @@ -528,7 +532,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ITEM_RELEASE_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 7; clear_u64_value(&p->motion.rot_spring_vel); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -554,14 +558,14 @@ int hero_set_state(int requested_state, int entry_animation_mode) { int i; float f; float t; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 3; p->rand_timer.range = 0x68; p->grind_direction = 1; p->grind_yaw_offset = -1.5707964f; p->rail_off_frames = 0; p->grind_anim_variant = 0; - if (p->state.prev_control_mode != 0xF) { + if (p->state.prev_control_mode != HERO_MODE_GRIND) { p->unk5AC.i = 0; p->grind_pose = -1; p->grind_base_speed = 0.0f; @@ -582,7 +586,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { fast_vec_sub(&d.v, &sampled_rail_position, &p->motion.pos); if (0.001f < fast_vec_length(&d.v)) { fast_vec_normalize(&d.v, &d.v, 1.0f); - if (p->state.prev_control_mode != 0xF) { + if (p->state.prev_control_mode != HERO_MODE_GRIND) { p->grind_base_speed = fast_vec_dot(&p->motion.displacement, &d.v); } } @@ -607,11 +611,11 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 24.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -627,7 +631,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -637,7 +641,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_SHIMMY_POSITIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (entry_animation_mode) @@ -646,7 +650,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_SHIMMY_NEGATIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (entry_animation_mode) @@ -655,7 +659,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -665,7 +669,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_FALL: case HERO_STATE_FATAL_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -704,7 +708,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_DELAYED_JUMP_OR_R1_REPEAT_EXIT_WAIT: { struct Hero *p = &hero; int animation_blend_spec = -2; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk22CA = 1; p->rand_timer.range = 0x68; p->unk2284 = 0; @@ -720,7 +724,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_LAND: { struct Hero *p = &hero; int landing_animation_blend_spec = -2; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->rand_timer.range = 0x68; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { @@ -758,7 +762,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { p->state_timer = p->state.prev_timer; return 0; } - p->state.control_mode = 4; + p->state.control_mode = HERO_MODE_JUMP; if (requested_state >= HERO_STATE_GRIND_JUMP && requested_state <= HERO_STATE_GRIND_RAIL_TRANSFER) { p->unk2284 = 3; @@ -829,11 +833,11 @@ int hero_set_state(int requested_state, int entry_animation_mode) { u->unk498 = scale_game_frames(2); u->jump_max_frames = scale_game_frames(0x78); hero_change_health(1); - if (current_level_index == 0xA) { + if (current_level_index == LEVEL_ORXON) { hero_set_state(0x7C, 1); return 0; } - if (current_level_index != 6) { + if (current_level_index != LEVEL_NEBULA_G34) { if (u->state.prev == 0x3C || u->state.prev2 == 0x3C || u->health.hp == 0) { struct Hero *w = &hero; w->sink_jump_count = w->sink_jump_count + 1; @@ -863,7 +867,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { u->jump_height_start = 2.4f; u->unk498 = scale_game_frames(0x11); u->jump_gravity = frame_time_sq * 27.0f; - u->state.control_mode = 0xF; + u->state.control_mode = HERO_MODE_GRIND; u->rail_gap_jump = 0; if (u->selector_5 != 0) { float h = 4.7f; @@ -895,7 +899,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { u->jump_height_start = 2.5f; u->unk498 = scale_game_frames(0xA); u->jump_gravity = frame_time_sq * 24.0f; - u->state.control_mode = 0xF; + u->state.control_mode = HERO_MODE_GRIND; u->rail_gap_jump = 0; } else if (u->state.current == 9) { u->unk430 = 1.0f; @@ -1139,7 +1143,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } else if (s == 0xA) { set_hero_animation(0x12, 0, (float)scale_game_frames(5)); } else if (s == 0x10) { - if (q->state.prev_control_mode == 4 || + if (q->state.prev_control_mode == HERO_MODE_JUMP || (q->state.prev == 4 && scale_game_frames(7) > q->state_timer)) { set_hero_animation(0x26, 0, (float)scale_game_frames(8)); q->takeoff_frame += scale_game_frames(3); @@ -1173,7 +1177,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *w = &hero; - if (w->state.prev_control_mode == 4) { + if (w->state.prev_control_mode == HERO_MODE_JUMP) { set_hero_animation(id, 1, (float)scale_game_frames(4)); w->takeoff_frame = scale_game_frames(1); } else { @@ -1192,7 +1196,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_ANIMATION_RECOVERY_WITH_JUMP_CANCEL: case HERO_STATE_VEHICLE_MODE_1_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->speed_scale = 1.0f; p->unk2284 = 0; p->heading_locked = 0; @@ -1291,7 +1295,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { e = &D_L06_0017C3A8[q->attack_record]; q->saved_item[0] = 0; k = 0; - if (q->state.prev_control_mode == 6 && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { + if (q->state.prev_control_mode == HERO_MODE_ATTACK && e->unk0 == 0 && + q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 3; } { @@ -1332,8 +1337,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { struct Hero *q = &hero; HeroTableRow2C *e = &D_L06_0017C3A8[q->attack_record]; int k = 0; - if ((q->state.prev_control_mode == 6 || - (q->state.prev2_control_mode == 6 && + if ((q->state.prev_control_mode == HERO_MODE_ATTACK || + (q->state.prev2_control_mode == HERO_MODE_ATTACK && (unsigned int)(q->moby->prev_seq - 0xF) < 2)) && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 2; @@ -1372,7 +1377,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_GRIND_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unkA64 = 0; if (p->state.prev == 0x2B) { p->attack_record = p->attack_record == 0; @@ -1423,7 +1428,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_HURT: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->unk1EE = scale_game_frames(0x2D); @@ -1447,7 +1452,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { break; } case HERO_STATE_DEATH_DESCENT: { - if (current_level_index == 6) { + if (current_level_index == LEVEL_NEBULA_G34) { int c0; int c1; int c2; @@ -1462,7 +1467,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->collision_off_frames = 0x2710; @@ -1476,7 +1481,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_VEHICLE_MODE_1_DEATH_DESCENT: { struct Hero *p = &hero; char *m; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->collision_off_frames = 0x2710; @@ -1490,7 +1495,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_1_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (p->on_slip_ground != 0 && p->frames_off_ground.s == 0) { hero_set_state(0x52, 1); @@ -1502,7 +1507,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_1_LAND: { struct Hero *p = &hero; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { scale_hero_motion(frame_time * 4.5f / p->motion.speed_xy); @@ -1514,7 +1519,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_1_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->stickless_decel = frame_time_sq * 7.0f; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1524,7 +1529,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_1_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -1533,7 +1538,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_1_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1556,12 +1561,12 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *q = &hero; - q->state.control_mode = 1; + q->state.control_mode = HERO_MODE_RUN; q->unk2284 = 0; q->ground_speed = vector_length_xy(&q->motion.resolved_velocity); if (q->state.prev == 3) q->ground_speed = 0.0f; - if (q->state.prev_control_mode == 0) + if (q->state.prev_control_mode == HERO_MODE_IDLE) q->ground_speed = vector_length_xy(&q->motion.momentum); q->unk3B8 = 0; if (entry_animation_mode) @@ -1571,7 +1576,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_1_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -1581,11 +1586,11 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ALT_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 12.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -1595,7 +1600,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ALT_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; if (entry_animation_mode) set_hero_animation(0xA, 0, (float)scale_game_frames(6)); @@ -1603,7 +1608,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ALT_LEDGE_SHIMMY_YAW_PLUS_90: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; if (entry_animation_mode) set_hero_animation(0xB, 0, (float)scale_game_frames(6)); @@ -1611,7 +1616,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ALT_LEDGE_SHIMMY_YAW_MINUS_90: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; if (entry_animation_mode) set_hero_animation(0xC, 0, (float)scale_game_frames(6)); @@ -1619,7 +1624,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (entry_animation_mode) set_hero_animation(0, 0, (float)scale_game_frames(0xE)); @@ -1627,7 +1632,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DELAYED_CIRCLE_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (entry_animation_mode) { set_hero_animation(4, 0, (float)scale_game_frames(7)); @@ -1637,7 +1642,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -1646,7 +1651,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1657,7 +1662,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; { char *v = (char *)&p->motion.resolved_velocity; @@ -1675,7 +1680,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -1684,7 +1689,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1700,7 +1705,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_GRIND_COLLISION_RECOVERY: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 0; if (p->rail_off_frames == 0) hero_change_health(1); @@ -1727,7 +1732,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_LOOK_RELEASE_WAIT: { struct Hero *p = &hero; p->unk2284 = 0x51; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; if (return_hero_animation_id_unchanged(p->moby->prev_seq) != get_hero_help_value(1)) { set_hero_animation(get_hero_help_value(1), 0, (float)scale_game_frames(5)); } @@ -1751,7 +1756,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_IDLE_ANIMATION_LONG_BLEND_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; set_hero_animation(get_hero_help_value(0), 0, (float)scale_game_frames(0xA)); break; @@ -1803,7 +1808,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode != 0xF && t->items[1].item_id == 0x1D && t->saved_item[1] != 0) { + if (t->state.control_mode != HERO_MODE_GRIND && t->items[1].item_id == 0x1D && + t->saved_item[1] != 0) { t->restore_item[1] = 1; } } @@ -1815,7 +1821,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode == 0x14) { + if (t->state.control_mode == HERO_MODE_DYING) { cancel_hero_item_animation(); t->item_use_locked = 1; } diff --git a/src/overlays/l06/hero/update_hero_motion_for_current_state.c b/src/overlays/l06/hero/update_hero_motion_for_current_state.c index 2aae0a3505..9d9a13aeff 100644 --- a/src/overlays/l06/hero/update_hero_motion_for_current_state.c +++ b/src/overlays/l06/hero/update_hero_motion_for_current_state.c @@ -155,10 +155,10 @@ s32 process_hero_hit_response(s32 apply_hurt_response) { f32 horizontal_hurt_impulse_scale, vertical_hurt_impulse_scale, hurt_impulse_scale; OvlVec4 hurt_impulse; - if (G.state.control_mode == 0x14) { + if (G.state.control_mode == HERO_MODE_DYING) { return 0; } - if (G.state.control_mode == 7) { + if (G.state.control_mode == HERO_MODE_HURT) { return 0; } if (G.state.current == 0x32) { @@ -185,7 +185,7 @@ s32 process_hero_hit_response(s32 apply_hurt_response) { D_0013DF88[current_level_index]++; G.damage_source_moby = (struct Moby *)hero_hit_entry->target; D_0015EEA8++; - if (G.state.control_mode == 0xF) { + if (G.state.control_mode == HERO_MODE_GRIND) { G.unk5BE = 1; return 0; } @@ -272,7 +272,7 @@ void update_hero_smoothed_parameters(void) { hero.capsule_radius_target = 0.45f; break; } - if (hero.state.control_mode == 4) { + if (hero.state.control_mode == HERO_MODE_JUMP) { if (hero.state_timer > hero.takeoff_frame && hero.past_jump_apex == 0) hero.capsule_bottom_target = hero.unk434; } else if (hero.state.current == HERO_STATE_FALL) { @@ -282,8 +282,8 @@ void update_hero_smoothed_parameters(void) { } else if (hero.state.current == HERO_STATE_SINK) { hero.capsule_radius_target = 0.8f; } - if (!hero.wall_hit || hero.state.prev_control_mode == 0x12 || hero.state.control_mode == 0x11 || - hero.base_condition || + if (!hero.wall_hit || hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE || + hero.state.control_mode == HERO_MODE_SWIM || hero.base_condition || vector_distance_xy(hero.wall_contact_point.f, hero.motion.pos.f) > hero.capsule_radius * 0.5f) { f32 *smoothing_state = D_0013F570; @@ -455,7 +455,7 @@ void update_hero_ground_contact(void) { if (hero_lui.gravity_mode) k = 1; ground_ray_start_offset = hero_lui.capsule_radius * 2.2f; - if (hero_lui.state.control_mode == 2) { + if (hero_lui.state.control_mode == HERO_MODE_FALL) { ground_ray_start_offset = hero_lui.capsule_radius * 2.9f; } hero_get_collision_ray_endpoints( @@ -479,7 +479,7 @@ void update_hero_ground_contact(void) { goto d1; } ground_sound_class = coll_sound_class(); - if (current_level_index == 1 || current_level_index == 0x12) { + if (current_level_index == LEVEL_NOVALIS || current_level_index == LEVEL_VELDIN2) { ground_sound_class = 3; } hero_lui.ground_sound_class = ground_sound_class; @@ -560,9 +560,11 @@ void update_hero_ground_contact(void) { hero_lui.unk2C8.i[1] = 0; hero_lui.unk2C0.i[0] = 0; hero_lui.unk2C0.i[1] = 0; - if (hero_lui.state.control_mode == 0xF || hero_lui.state.control_mode == 0x15 || - hero_lui.state.control_mode == 6 || hero_lui.state.control_mode == 4 || - hero_lui.state.control_mode == 5 || hero_lui.state.control_mode == 3) { + if (hero_lui.state.control_mode == HERO_MODE_GRIND || hero_lui.state.control_mode == 0x15 || + hero_lui.state.control_mode == HERO_MODE_ATTACK || + hero_lui.state.control_mode == HERO_MODE_JUMP || + hero_lui.state.control_mode == HERO_MODE_LAND || + hero_lui.state.control_mode == HERO_MODE_LEDGE) { return; } if (!(hero_lui.ground_distance < 0.25f)) { @@ -760,7 +762,7 @@ void update_hero_airborne_planar_velocity(void) { qcopy(&hero.motion.momentum, &hero.move_impulse); velocity_adjustment_step = ED70 * 20.0f; if (hero.target_speed < hero_airborne_deceleration_speed_reference[0] * ED6C * 0.2f) { - if (hero.state.control_mode == 2) { + if (hero.state.control_mode == HERO_MODE_FALL) { speed_decay_step = hero.stickless_decel; speed = vector_length_xy(&hero.motion.velocity); approach_value_2b438(0.0f, speed_decay_step, &speed); diff --git a/src/overlays/l06/hero/update_hero_state_machine.c b/src/overlays/l06/hero/update_hero_state_machine.c index 0bc9c76598..03cae11232 100644 --- a/src/overlays/l06/hero/update_hero_state_machine.c +++ b/src/overlays/l06/hero/update_hero_state_machine.c @@ -172,7 +172,7 @@ void update_hero_state_machine(void) { prevState = hero.state.step; prevAnim = MOBY(moby)->prev_seq; if (process_hero_hit_response(1) == 0) { - if (hero.health.hp <= 0 && hero.state.control_mode != 0x14 && + if (hero.health.hp <= 0 && hero.state.control_mode != HERO_MODE_DYING && (hero.state.current == HERO_STATE_IDLE || hero.state.current == HERO_STATE_RUN)) { hero_set_state(HERO_STATE_DYING, 1); } else if (process_hero_item_action_input() == 0 && @@ -443,7 +443,7 @@ void update_hero_state_machine(void) { } } if (ok && 0.22f < hero.stick_magnitude) { - if (current_level_index == 0xC) { + if (current_level_index == LEVEL_HOVEN) { int slot = hero.ground_sound_class; request_hero_voice_if_enabled(slot, 0, 0); request_hero_voice_if_enabled(slot, 1, 0); @@ -671,7 +671,8 @@ void update_hero_state_machine(void) { break; } if (!(hero.air_frames.s < scale_game_frames(5)) && - !(hero.state.prev_control_mode == 0x12 && hero.wading != 0) && + !(hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE && + hero.wading != 0) && hero.ground_distance > 1.35f) { if (check_hero_forward_collision_height() == 0) { hero_set_state(HERO_STATE_FALL, 1); @@ -726,7 +727,8 @@ void update_hero_state_machine(void) { break; } if (hero.state_timer > scale_game_frames(0xF) || - (hero.state.prev_control_mode != 0 && hero.state.prev_control_mode != 1)) { + (hero.state.prev_control_mode != HERO_MODE_IDLE && + hero.state.prev_control_mode != HERO_MODE_RUN)) { if ((controller_state.pressed & 0x10000) && hero.unk20AA == 0) { hero.unk3BE = 1; } @@ -1014,7 +1016,7 @@ void update_hero_state_machine(void) { } else { int ice = 0; - if (current_level_index == 0x10 && hero.wall_hit != 0 && + if (current_level_index == LEVEL_KALEBO3 && hero.wall_hit != 0 && ((unsigned char *)hero.coll_hit_moby) != 0 && *(short *)(((unsigned char *)hero.coll_hit_moby) + 0xA6) == 0x101) { ice = 1; @@ -1025,7 +1027,7 @@ void update_hero_state_machine(void) { ice || hero.unk5BE != 0) { int ok = 1; - if (current_level_index != 0x10) { + if (current_level_index != LEVEL_KALEBO3) { qcopy(scratch_position, hero.rail_point.f); scratch_position[2] += 2.0f; scratch_motion_vector[0] = fast_cos(hero.rail_dir_yaw) * 5.0f; @@ -1077,7 +1079,7 @@ void update_hero_state_machine(void) { if (hero.state.current == HERO_STATE_GRIND) { int can = 1; - if (current_level_index == 8) { + if (current_level_index == LEVEL_BATALIA) { *(OvlQuad *)scratch_position = 0; scratch_position[0] = 342.0f; scratch_position[1] = 111.1f; @@ -1585,9 +1587,9 @@ void update_hero_state_machine(void) { } break; case HERO_STATE_FATAL_FALL: - if ((current_level_index == 3 && 5.0f > hero.motion.pos.f[2]) || - (current_level_index == 6 && 50.0f > hero.motion.pos.f[2]) || - (current_level_index == 0x10 && + if ((current_level_index == LEVEL_KERWAN && 5.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_NEBULA_G34 && 50.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_KALEBO3 && (77.0f > hero.motion.pos.f[2] || (hero.state_timer > 0x14 && hero.wall_hit != 0 && hero.motion.displacement.f[2] >= 0.0f))) || @@ -2096,8 +2098,8 @@ void update_hero_state_machine(void) { hero_set_state(HERO_STATE_FALL, 1); break; } - if (current_level_index == 0x10 && 0.0f > hero.motion.velocity.f[2] && - hero.health.hp == 0 && hero.state.prev_control_mode == 0xF) { + if (current_level_index == LEVEL_KALEBO3 && 0.0f > hero.motion.velocity.f[2] && + hero.health.hp == 0 && hero.state.prev_control_mode == HERO_MODE_GRIND) { hero_set_state(0x77, 1); break; } @@ -2328,7 +2330,7 @@ void update_hero_state_machine(void) { } break; case HERO_STATE_VEHICLE_MODE_1_FALL: - if (current_level_index == 6 && 115.0f > hero.motion.pos.f[2]) { + if (current_level_index == LEVEL_NEBULA_G34 && 115.0f > hero.motion.pos.f[2]) { goto respawn; } if (hero.air_frames.s == 0) { diff --git a/src/overlays/l06/mobys/fred.c b/src/overlays/l06/mobys/fred.c index 861a46e2f6..e6be0ee4cb 100644 --- a/src/overlays/l06/mobys/fred.c +++ b/src/overlays/l06/mobys/fred.c @@ -169,7 +169,7 @@ void fred_update(struct Moby *moby) { begin_dialogue_camera_transition(2.2f, moby); } } - if (hero.state.control_mode == 15) { + if (hero.state.control_mode == HERO_MODE_GRIND) { set_moby_and_links_to_states_4_and_5(D_L06_0015FFD8_301070 + (fred_vars->f160 << 8)); } break; @@ -287,7 +287,7 @@ void fred_update(struct Moby *moby) { } break; case WAIT_FOR_FRED_REMOVAL_TRIGGER: - if (hero.state.control_mode == 15) { + if (hero.state.control_mode == HERO_MODE_GRIND) { set_moby_and_links_to_states_4_and_5(D_L06_0015FFD8_301070 + (fred_vars->f164 << 8)); del: mark_moby_for_removal(moby); diff --git a/src/overlays/l06/render_sky_with_gif_paging.c b/src/overlays/l06/render_sky_with_gif_paging.c index f8e3f19d3d..614dbf39bf 100644 --- a/src/overlays/l06/render_sky_with_gif_paging.c +++ b/src/overlays/l06/render_sky_with_gif_paging.c @@ -12,7 +12,7 @@ void render_sky_with_gif_paging(void) __asm__("FUN_L06_0024d218"); void render_sky_with_gif_paging(void) { setup_sky_gif_paging(); - if (current_level_index == 0x6) { + if (current_level_index == LEVEL_NEBULA_G34) { draw_three_sky_shells_with_three_particle_types(); } else { update_sky_shells_static(); diff --git a/src/overlays/l07/draw_sky_with_gif_paging.c b/src/overlays/l07/draw_sky_with_gif_paging.c index e008aa9cdc..7e072898fc 100644 --- a/src/overlays/l07/draw_sky_with_gif_paging.c +++ b/src/overlays/l07/draw_sky_with_gif_paging.c @@ -11,7 +11,7 @@ void draw_sky_with_gif_paging(void) __asm__("FUN_L07_00265b58"); void draw_sky_with_gif_paging(void) { setup_sky_gif_paging(); - if (current_level_index == 0x7) { + if (current_level_index == LEVEL_UMBRIS) { draw_three_sky_shells_with_particles_and_modulo_50000_rotation(); } else { update_sky_shells_static(); diff --git a/src/overlays/l07/mobys/register_level07_moby_draw_callback.c b/src/overlays/l07/mobys/register_level07_moby_draw_callback.c index 5544d31f7e..22651ff862 100644 --- a/src/overlays/l07/mobys/register_level07_moby_draw_callback.c +++ b/src/overlays/l07/mobys/register_level07_moby_draw_callback.c @@ -25,8 +25,8 @@ extern void func_00233AB8(void *) __asm__("FUN_L07_002ba260"); void register_level07_moby_draw_callback(void) __asm__("FUN_L07_00265bd8"); void register_level07_moby_draw_callback(void) { - if (current_level_index == 7 && D_L07_0016C8E0.state == 4 && D_L07_0016C8E0.moby != 0 && - D_L07_0016C8E0.moby->class_id == 0x214) { + if (current_level_index == LEVEL_UMBRIS && D_L07_0016C8E0.state == 4 && + D_L07_0016C8E0.moby != 0 && D_L07_0016C8E0.moby->class_id == 0x214) { add_draw_callback(func_00233AB8, D_L07_0016C8E0.moby); } } diff --git a/src/overlays/l08/hero/hero_set_state.c b/src/overlays/l08/hero/hero_set_state.c index 8f579d8410..103e4fe361 100644 --- a/src/overlays/l08/hero/hero_set_state.c +++ b/src/overlays/l08/hero/hero_set_state.c @@ -75,7 +75,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { float grind_vector_scratch[4]; { struct Hero *p = &hero; - if (p->state.control_mode == 0x14 && + if (p->state.control_mode == HERO_MODE_DYING && (requested_state != HERO_STATE_IDLE_ANIMATION_WITH_DYING_OVERRIDE || animation_request_mode != HERO_ANIMATION_ENTRY_OVERRIDE_GUARDS)) return 0; @@ -85,7 +85,8 @@ int hero_set_state(int requested_state, int animation_request_mode) { return 0; { struct Hero *p = &hero; - if (p->health.hp == 0 && (p->state.control_mode == 2 || p->state.control_mode == 7) && + if (p->health.hp == 0 && + (p->state.control_mode == HERO_MODE_FALL || p->state.control_mode == HERO_MODE_HURT) && requested_state != HERO_STATE_FALL && requested_state != HERO_STATE_DYING && requested_state != HERO_STATE_VEHICLE_MODE_1_DYING && requested_state != HERO_STATE_VEHICLE_MODE_3_DYING && @@ -136,7 +137,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { switch (requested_state) { case HERO_STATE_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; p->unk1010 = random_int_between(scale_game_frames(0x32), scale_game_frames(0x64)); clear_hero_idle_rotation_targets(); @@ -165,7 +166,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_AT_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; clear_u64_value(&p->motion.momentum); p->rand_timer.range = 0x68; @@ -192,7 +193,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (animation_request_mode) @@ -201,7 +202,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_DYING_SPEED_LIMITED: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -212,7 +213,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_SINK: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->unk694 = p->motion.displacement.f[2] * 0.2f; @@ -228,11 +229,11 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_SWIM: { struct Hero *p = &hero; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; *(int *)&p->drown_sink_speed = 0; - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } else { @@ -252,11 +253,11 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_SWIM_WITH_CROUCH_INPUT: { struct Hero *p = &hero; int n; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; p->unk8F4 = scale_game_frames(0x3C); - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } @@ -273,7 +274,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { struct Hero *p = &hero; int n; int t; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -288,11 +289,11 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_WATER_SURFACE_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; p->splash_effect_timer = 0; - if (p->state.prev_control_mode == 0x11) { + if (p->state.prev_control_mode == HERO_MODE_SWIM) { emit_hero_surface_effect_burst(3, 0xA, 0); if (D_L08_001612D0 != 0) { pool_splash(D_L08_001612D0, @@ -323,7 +324,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { { struct Hero *q = &hero; q->unk698 = 0; - if (q->state.prev_control_mode == 0x11) { + if (q->state.prev_control_mode == HERO_MODE_SWIM) { float d = (float)q->underwater_air; if (d < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); @@ -332,7 +333,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } { struct Hero *r = &hero; - if (r->state.prev_control_mode == 0x11) { + if (r->state.prev_control_mode == HERO_MODE_SWIM) { float e = (float)r->underwater_air; if (e < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); @@ -364,7 +365,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->item_select_blocked = 1; @@ -396,7 +397,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_WATER_SURFACE_MOVE: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; *(int *)&p->drown_sink_speed = 0; @@ -408,7 +409,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_DROWN: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -448,7 +449,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_DYING_ZERO_HEALTH: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -460,7 +461,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_LOOK: { struct Hero *p = &hero; int t; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 4; *(int *)&D_L08_0015F688 = scale_game_frames(0x3C); if (p->unk20AA == 0) { @@ -473,7 +474,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_ITEM_BUTTON_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(0xA)); @@ -482,7 +483,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_WAIT_FOR_ITEM_RELEASE_THEN_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(5)); @@ -491,7 +492,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_ITEM_BUTTON_HOLD_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.displacement); p->state.step = 0; @@ -504,9 +505,10 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_DIRECTION_LIMITED_GROUND_MOVE: case HERO_STATE_SHALLOW_WATER_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; - if (p->state.prev_control_mode != 4 && p->state.prev2_control_mode != 4) { + if (p->state.prev_control_mode != HERO_MODE_JUMP && + p->state.prev2_control_mode != HERO_MODE_JUMP) { p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); } { @@ -517,7 +519,8 @@ int hero_set_state(int requested_state, int animation_request_mode) { stick_target(1.0f, 0); if (1.5707964f < fast_difference_between_rotations(q->motion.rot.f[2], q->motion.move_yaw)) { - if (q->state.prev_control_mode == 7 || q->state.prev == 3 || q->state.prev2 == 3) { + if (q->state.prev_control_mode == HERO_MODE_HURT || q->state.prev == 3 || + q->state.prev2 == 3) { struct Hero *r = &hero; r->ground_speed = 0.0f; } @@ -553,7 +556,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { n = scale_game_frames(0x12); { struct Hero *u = &hero; - if (u->state.prev2_control_mode == 4 && + if (u->state.prev2_control_mode == HERO_MODE_JUMP && scale_game_frames(5) < u->rail_land_frames) n = scale_game_frames(0xD); } @@ -567,7 +570,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_ANIMATION_FRAME_EXIT_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; if (animation_request_mode) { if (p->state.prev == 4) { @@ -580,7 +583,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_APPROACH_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->item_use_locked = 1; @@ -611,7 +614,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_STOP: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (p->on_slip_ground != 0 && p->frames_off_ground.s == 0) { @@ -640,7 +643,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_BRAKE_AT_TARGET_POSITION: { struct Hero *p = &hero; char *v = (char *)&p->motion.resolved_velocity; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = gravity_length_xy((float *)v); qcopy(&p->motion.momentum, v); @@ -655,7 +658,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_CROUCH: { struct Hero *p = &hero; - p->state.control_mode = 0xC; + p->state.control_mode = HERO_MODE_CROUCH; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); if (frame_time * 7.0f < p->ground_speed) @@ -684,7 +687,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_GRAPPLE_TARGET_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -706,7 +709,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_APPROACH_TARGET_MOBY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; *(int *)&p->grapple_pull_speed = 0; p->grapple_pull_ending = 0; @@ -717,7 +720,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_CONSTRAIN_TO_TARGET_RADIUS: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; p->item_use_locked = 1; *(int *)&p->grapple_pull_speed = 0; @@ -730,7 +733,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_GRAPPLE_SWING_ENTRY: { struct Hero *p = &hero; char *d; - p->state.control_mode = 0xE; + p->state.control_mode = HERO_MODE_GRAPPLE_SWING; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -774,9 +777,9 @@ int hero_set_state(int requested_state, int animation_request_mode) { q->swing_target_moby->pos.y - q->motion.pos.f[1]); q->unk9A4 = fast_vec_dist(&q->motion.pos, &q->swing_target_moby->pos); q->swing_gravity = frame_time_sq * 27.0f; - if (q->state.prev_control_mode == 4) { + if (q->state.prev_control_mode == HERO_MODE_JUMP) { q->swing_gravity = q->jump_gravity; - } else if (q->state.prev_control_mode == 2) { + } else if (q->state.prev_control_mode == HERO_MODE_FALL) { q->swing_gravity = q->fall_state_gravity; } if (animation_request_mode) { @@ -791,7 +794,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_ITEM_RELEASE_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 7; clear_u64_value(&p->motion.rot_spring_vel); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -816,14 +819,14 @@ int hero_set_state(int requested_state, int animation_request_mode) { float pos[4]; int seg; float t; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 3; p->rand_timer.range = 0x68; p->rail_off_frames = 0; p->grind_direction = 1; p->grind_yaw_offset = -1.5707964f; p->grind_anim_variant = 0; - if (p->state.prev_control_mode != 0xF) { + if (p->state.prev_control_mode != HERO_MODE_GRIND) { p->grind_pose = -1; p->unk5AC.i = 0; p->grind_base_speed = 0.0f; @@ -838,7 +841,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { fast_vec_sub(grind_vector_scratch, pos, &p->motion.pos); if (0.001f < fast_vec_length(grind_vector_scratch)) { fast_vec_normalize(grind_vector_scratch, grind_vector_scratch, 1.0f); - if (p->state.prev_control_mode != 0xF) { + if (p->state.prev_control_mode != HERO_MODE_GRIND) { p->grind_base_speed = fast_vec_dot(&p->motion.displacement, grind_vector_scratch); } } @@ -865,11 +868,11 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 24.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -885,7 +888,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -895,7 +898,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_LEDGE_SHIMMY_POSITIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (animation_request_mode) @@ -904,7 +907,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_LEDGE_SHIMMY_NEGATIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (animation_request_mode) @@ -913,7 +916,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (animation_request_mode) @@ -923,7 +926,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_FALL: case HERO_STATE_FATAL_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -958,7 +961,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_DELAYED_JUMP_OR_R1_REPEAT_EXIT_WAIT: { struct Hero *p = &hero; int animation_timing_profile_selector = -2; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk22CA = 1; p->rand_timer.range = 0x68; p->unk2284 = 0; @@ -974,7 +977,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_LAND: { struct Hero *p = &hero; int animation_timing_selector = -2; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->rand_timer.range = 0x68; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { @@ -1012,7 +1015,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { p->state_timer = p->state.prev_timer; return 0; } - p->state.control_mode = 4; + p->state.control_mode = HERO_MODE_JUMP; if (requested_state >= HERO_STATE_GRIND_JUMP && requested_state <= HERO_STATE_GRIND_RAIL_TRANSFER) { p->unk2284 = 3; @@ -1111,7 +1114,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { u->unk48C = 2.45f; u->jump_height_start = 2.4f; u->unk498 = scale_game_frames(0x11); - u->state.control_mode = 0xF; + u->state.control_mode = HERO_MODE_GRIND; u->rail_gap_jump = 0; u->jump_gravity = frame_time_sq * 27.0f; if (u->selector_5 != 0) { @@ -1141,7 +1144,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { u->unk48C = 2.55f; u->jump_height_start = 2.5f; u->unk498 = scale_game_frames(0xA); - u->state.control_mode = 0xF; + u->state.control_mode = HERO_MODE_GRIND; u->rail_gap_jump = 0; u->jump_gravity = frame_time_sq * 24.0f; } else if (u->state.current == 9) { @@ -1359,7 +1362,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } else if (s == 0xA) { set_hero_animation(0x12, 0, (float)scale_game_frames(5)); } else if (s == 0x10) { - if (q->state.prev_control_mode == 4 || + if (q->state.prev_control_mode == HERO_MODE_JUMP || (q->state.prev == 4 && scale_game_frames(7) > q->state_timer)) { set_hero_animation(0x26, 0, (float)scale_game_frames(8)); q->takeoff_frame += scale_game_frames(3); @@ -1391,7 +1394,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } { struct Hero *w = &hero; - if (w->state.prev_control_mode == 4) { + if (w->state.prev_control_mode == HERO_MODE_JUMP) { set_hero_animation(id, 1, (float)scale_game_frames(4)); w->takeoff_frame = scale_game_frames(1); } else { @@ -1410,7 +1413,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_ANIMATION_RECOVERY_WITH_JUMP_CANCEL: case HERO_STATE_VEHICLE_MODE_1_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->speed_scale = 1.0f; p->unk2284 = 0; p->heading_locked = 0; @@ -1509,7 +1512,8 @@ int hero_set_state(int requested_state, int animation_request_mode) { e = &D_L08_0017C428[q->attack_record]; q->saved_item[0] = 0; k = 0; - if (q->state.prev_control_mode == 6 && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { + if (q->state.prev_control_mode == HERO_MODE_ATTACK && e->unk0 == 0 && + q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 3; } { @@ -1564,7 +1568,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_ATTACK_RECORD_FRAME_EXIT_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unkA64 = 0; if (p->state.prev == 0x70) { int v = 5; @@ -1591,7 +1595,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_GRIND_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unkA64 = 0; if (p->state.prev == 0x2B) { p->attack_record = p->attack_record == 0; @@ -1642,7 +1646,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_HURT: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->unk1EE = scale_game_frames(0x2D); @@ -1667,7 +1671,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_VEHICLE_MODE_3_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (animation_request_mode) set_hero_animation(0, 0, (float)scale_game_frames(0xE)); @@ -1675,7 +1679,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_DELAYED_CIRCLE_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (animation_request_mode) { set_hero_animation(4, 0, (float)scale_game_frames(7)); @@ -1685,7 +1689,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_VEHICLE_MODE_3_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (animation_request_mode) @@ -1694,7 +1698,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_VEHICLE_MODE_3_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1705,7 +1709,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_VEHICLE_MODE_3_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; { char *v = (char *)&p->motion.resolved_velocity; @@ -1723,7 +1727,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_VEHICLE_MODE_3_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (animation_request_mode) @@ -1732,7 +1736,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_VEHICLE_MODE_3_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1748,7 +1752,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_GRIND_COLLISION_RECOVERY: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 0; if (p->rail_off_frames == 0) hero_change_health(1); @@ -1775,7 +1779,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { case HERO_STATE_LOOK_RELEASE_WAIT: { struct Hero *p = &hero; p->unk2284 = 0x51; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; if (return_hero_animation_id_unchanged(p->moby->prev_seq) != get_hero_idle_animation_index(1)) { set_hero_animation(get_hero_idle_animation_index(1), 0, (float)scale_game_frames(5)); @@ -1800,7 +1804,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } case HERO_STATE_IDLE_ANIMATION_LONG_BLEND_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(0xA)); break; @@ -1866,7 +1870,8 @@ int hero_set_state(int requested_state, int animation_request_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode != 0xF && t->items[1].item_id == 0x1D && t->saved_item[1] != 0) { + if (t->state.control_mode != HERO_MODE_GRIND && t->items[1].item_id == 0x1D && + t->saved_item[1] != 0) { t->restore_item[1] = 1; } } @@ -1878,7 +1883,7 @@ int hero_set_state(int requested_state, int animation_request_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode == 0x14) { + if (t->state.control_mode == HERO_MODE_DYING) { cancel_hero_item_animation(); t->item_use_locked = 1; } diff --git a/src/overlays/l08/hero/update_hero_motion_for_current_state.c b/src/overlays/l08/hero/update_hero_motion_for_current_state.c index ac2f58bb1a..e84f5ff86f 100644 --- a/src/overlays/l08/hero/update_hero_motion_for_current_state.c +++ b/src/overlays/l08/hero/update_hero_motion_for_current_state.c @@ -79,7 +79,7 @@ void apply_hero_ground_type_effects(void) { q = &hero; q->base_condition = 1; } - if (current_level_index == 0xD) { + if (current_level_index == LEVEL_OLTANIS_ORBIT) { struct Hero *q = &hero; if (q->state.current != 0x7B) { if (coll_sphere(q->capsule_radius + 0.03f, &q->motion.body_center, 2, 0)) { @@ -1860,12 +1860,12 @@ void update_hero_motion_for_current_state(void) { f32 f; f32 old; f32 d; - if (current_level_index == 0xF) { + if (current_level_index == LEVEL_QUARTU) { release_voice_slot_cf(2, MV(hero.moby), 0x1D); } else { release_voice_slot_cf(2, MV(hero.moby), 6); } - if (current_level_index != 0xF) { + if (current_level_index != LEVEL_QUARTU) { emit_hero_randomized_motion_effects(4, 2); vector_and_attack_descriptor_scratch.f[0] = hero.motion.pos.f[0] + random_float_between(-0.25f, 0.25f); diff --git a/src/overlays/l08/hero/update_hero_state_transitions.c b/src/overlays/l08/hero/update_hero_state_transitions.c index e9e754ba1a..f80d3811f4 100644 --- a/src/overlays/l08/hero/update_hero_state_transitions.c +++ b/src/overlays/l08/hero/update_hero_state_transitions.c @@ -181,7 +181,7 @@ void update_hero_state_transitions(void) { prevState = hero.state.step; prevAnim = MOBY(moby)->prev_seq; if (handle_hero_hit(1) == 0) { - if (hero.health.hp <= 0 && hero.state.control_mode != 0x14 && + if (hero.health.hp <= 0 && hero.state.control_mode != HERO_MODE_DYING && (hero.state.current == HERO_STATE_IDLE || hero.state.current == HERO_STATE_RUN)) { hero_set_state(HERO_STATE_DYING, 1); } else if (process_hero_item_action_input() == 0 && try_enter_hero_water_state() == 0 && @@ -441,7 +441,7 @@ void update_hero_state_transitions(void) { } } if (ok && 0.22f < hero.stick_magnitude) { - if (current_level_index == 0xC) { + if (current_level_index == LEVEL_HOVEN) { int slot = hero.ground_sound_class; request_hero_voice_if_enabled(slot, 0, 0); request_hero_voice_if_enabled(slot, 1, 0); @@ -632,7 +632,8 @@ void update_hero_state_transitions(void) { break; case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: if (hero.health.hp <= 0) { - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || + current_level_index == LEVEL_VELDIN_ORBIT) { hero_set_state(0x82, 1); break; } @@ -810,7 +811,8 @@ void update_hero_state_transitions(void) { break; } if (!(hero.air_frames.s < scale_game_frames(5)) && - !(hero.state.prev_control_mode == 0x12 && hero.wading != 0) && + !(hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE && + hero.wading != 0) && hero.ground_distance > 1.35f) { if (check_hero_forward_collision_height() == 0) { hero_set_state(HERO_STATE_FALL, 1); @@ -877,7 +879,8 @@ void update_hero_state_transitions(void) { break; } if (hero.state_timer > scale_game_frames(0xF) || - (hero.state.prev_control_mode != 0 && hero.state.prev_control_mode != 1)) { + (hero.state.prev_control_mode != HERO_MODE_IDLE && + hero.state.prev_control_mode != HERO_MODE_RUN)) { if ((controller_state.pressed & 0x10000) && hero.unk20AA == 0) { hero.unk3BE = 1; } @@ -1244,7 +1247,7 @@ void update_hero_state_transitions(void) { } else { int ice = 0; - if (current_level_index == 0x10 && hero.wall_hit != 0 && + if (current_level_index == LEVEL_KALEBO3 && hero.wall_hit != 0 && ((unsigned char *)hero.coll_hit_moby) != 0 && *(short *)(((unsigned char *)hero.coll_hit_moby) + 0xA6) == 0x101) { ice = 1; @@ -1255,7 +1258,7 @@ void update_hero_state_transitions(void) { ice || hero.unk5BE != 0) { int ok = 1; - if (current_level_index != 0x10) { + if (current_level_index != LEVEL_KALEBO3) { qcopy(position_scratch, hero.rail_point.f); position_scratch[2] += 2.0f; movement_query_scratch[0] = fast_cos(hero.rail_dir_yaw) * 5.0f; @@ -1308,7 +1311,7 @@ void update_hero_state_transitions(void) { if (hero.state.current == HERO_STATE_GRIND) { int can = 1; - if (current_level_index == 8) { + if (current_level_index == LEVEL_BATALIA) { *(OvlQuad *)position_scratch = 0; position_scratch[0] = 342.0f; position_scratch[1] = 111.1f; @@ -1816,9 +1819,9 @@ void update_hero_state_transitions(void) { } break; case HERO_STATE_FATAL_FALL: - if ((current_level_index == 3 && 5.0f > hero.motion.pos.f[2]) || - (current_level_index == 6 && 50.0f > hero.motion.pos.f[2]) || - (current_level_index == 0x10 && + if ((current_level_index == LEVEL_KERWAN && 5.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_NEBULA_G34 && 50.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_KALEBO3 && (77.0f > hero.motion.pos.f[2] || (hero.state_timer > 0x14 && hero.wall_hit != 0 && hero.motion.displacement.f[2] >= 0.0f))) || @@ -2326,8 +2329,8 @@ void update_hero_state_transitions(void) { hero_set_state(HERO_STATE_FALL, 1); break; } - if (current_level_index == 0x10 && hero.motion.velocity.f[2] < 0.0f && - hero.health.hp == 0 && hero.state.prev_control_mode == 0xF) { + if (current_level_index == LEVEL_KALEBO3 && hero.motion.velocity.f[2] < 0.0f && + hero.health.hp == 0 && hero.state.prev_control_mode == HERO_MODE_GRIND) { hero_set_state(0x77, 1); break; } diff --git a/src/overlays/l08/mobys/help_hints.c b/src/overlays/l08/mobys/help_hints.c index 194327d991..eca4f69f49 100644 --- a/src/overlays/l08/mobys/help_hints.c +++ b/src/overlays/l08/mobys/help_hints.c @@ -41,7 +41,7 @@ void help_hints_update(struct Moby *moby) { switch (event_trigger_data->state) { case VENDOR_EVENT_WAIT_FOR_ARMING: if (is_point_inside_clip_volume(&hero.motion.pos, event_trigger_data->third) && - hero.state.control_mode == 15) + hero.state.control_mode == HERO_MODE_GRIND) event_trigger_data->state = VENDOR_EVENT_ARMED; break; case VENDOR_EVENT_ARMED: @@ -135,6 +135,6 @@ void help_hints_update(struct Moby *moby) { volume[2] = -1.0f; if (fast_vec_dot((char *)&hero + 0x290, volume) < 0.1f) help_records[112].count = -1; - if (alternate_item_available[47] == 0 && hero.state.control_mode == 15) + if (alternate_item_available[47] == 0 && hero.state.control_mode == HERO_MODE_GRIND) alternate_item_available[47] = 1; } diff --git a/src/overlays/l08/mobys/water_surface.c b/src/overlays/l08/mobys/water_surface.c index 73cedf6f83..a214c8fc23 100644 --- a/src/overlays/l08/mobys/water_surface.c +++ b/src/overlays/l08/mobys/water_surface.c @@ -48,7 +48,7 @@ void water_surface_update(struct Moby *moby) { prepare_scaled_table_with_byte_128(water_entry_plane_data, 0.6666667f); } add_draw_callback(FUN_L08_002da0d0, moby); - if (current_level_index != 8) + if (current_level_index != LEVEL_BATALIA) return; if (!(hero.motion.pos.f[2] < water_entry_plane_data[2])) return; diff --git a/src/overlays/l08/render_sky_shells.c b/src/overlays/l08/render_sky_shells.c index 0e116fb232..62e3fa78f5 100644 --- a/src/overlays/l08/render_sky_shells.c +++ b/src/overlays/l08/render_sky_shells.c @@ -11,7 +11,7 @@ void render_sky_shells(void) __asm__("FUN_L08_00248148"); void render_sky_shells(void) { setup_sky_gif_paging(); - if (current_level_index == 0x8) { + if (current_level_index == LEVEL_BATALIA) { draw_sky_shells_with_modulo_40000_rotation(); } else { update_sky_shells_static(); diff --git a/src/overlays/l09/mobys/turret.c b/src/overlays/l09/mobys/turret.c index fa62b9adca..17f2e598ba 100644 --- a/src/overlays/l09/mobys/turret.c +++ b/src/overlays/l09/mobys/turret.c @@ -115,8 +115,8 @@ void turret_update(struct Moby *moby) { seat.f[2] += 0.4f; if (moby->state >= TURRET_STATE_IDLE) { if (fast_dec_timer_s16(&turret_vars->mount_delay) != 0 && moby->command == 1 && - hero.state.control_mode != 0x14 && hero.state.control_mode != 7 && - hero.state.current != 0x3D) { + hero.state.control_mode != HERO_MODE_DYING && + hero.state.control_mode != HERO_MODE_HURT && hero.state.current != 0x3D) { qcopy(&hero.motion.pos, &seat); qcopy(&hero.motion.rot, &moby->rot); hero.motion.rot.f[2] = fast_add_rotations(1.5707964f, hero.motion.rot.f[2]); @@ -146,9 +146,10 @@ void turret_update(struct Moby *moby) { moby->command = 0; turret_vars->mount_delay = scale_game_frames(60); } - } else if (hero.state.control_mode != 0x14 && hero.state.control_mode != 7 && - hero.state.current != 0x3D && hero.ground_moby == moby && - fast_vec_dist(&seat, &hero.moby->pos) < 1.2f && turret_vars->mount_delay == 0) { + } else if (hero.state.control_mode != HERO_MODE_DYING && + hero.state.control_mode != HERO_MODE_HURT && hero.state.current != 0x3D && + hero.ground_moby == moby && fast_vec_dist(&seat, &hero.moby->pos) < 1.2f && + turret_vars->mount_delay == 0) { moby->command = 1; hero_set_state(0x32, 1); } diff --git a/src/overlays/l09/render_sky_shells.c b/src/overlays/l09/render_sky_shells.c index 944899987d..6c8acb73b0 100644 --- a/src/overlays/l09/render_sky_shells.c +++ b/src/overlays/l09/render_sky_shells.c @@ -11,7 +11,7 @@ void render_sky_shells(void) __asm__("FUN_L09_0025d648"); void render_sky_shells(void) { setup_sky_gif_paging(); - if (current_level_index == 0x9) { + if (current_level_index == LEVEL_GASPAR) { draw_sky_shells_with_modulo_25000_rotation(); } else { update_sky_shells_static(); diff --git a/src/overlays/l10/draw_sky_shells_with_gif_paging.c b/src/overlays/l10/draw_sky_shells_with_gif_paging.c index 50c8349cf4..928fbe6a46 100644 --- a/src/overlays/l10/draw_sky_shells_with_gif_paging.c +++ b/src/overlays/l10/draw_sky_shells_with_gif_paging.c @@ -11,7 +11,7 @@ void draw_sky_shells_with_gif_paging(void) __asm__("FUN_L10_00230fd0"); void draw_sky_shells_with_gif_paging(void) { setup_sky_gif_paging(); - if (current_level_index == 0xa) { + if (current_level_index == LEVEL_ORXON) { draw_sky_shells_with_scaled_phase_rotation(); } else { update_sky_shells_static(); diff --git a/src/overlays/l10/mobys/data_processor_linked_effect.c b/src/overlays/l10/mobys/data_processor_linked_effect.c index c07e787bd4..c219e692c7 100644 --- a/src/overlays/l10/mobys/data_processor_linked_effect.c +++ b/src/overlays/l10/mobys/data_processor_linked_effect.c @@ -77,7 +77,7 @@ void data_processor_linked_effect_update(struct Moby *moby) { } switch (moby->state) { case MOBY_STATE_INITIALIZE: - if (current_level_index == 10 && D_001413F4[0] == 1) { + if (current_level_index == LEVEL_ORXON && D_001413F4[0] == 1) { mark_moby_for_removal(moby); break; } diff --git a/src/overlays/l10/mobys/gate.c b/src/overlays/l10/mobys/gate.c index d9266b2379..72333ceeae 100644 --- a/src/overlays/l10/mobys/gate.c +++ b/src/overlays/l10/mobys/gate.c @@ -52,7 +52,7 @@ void gate_update(unsigned char *gate_moby) { l10_save_state.cleared[((short)MOBY(gate_moby)->save_id)] = gate_moby[0xB0] + 2; } gate_moby[0x20] = 2; - if (current_level_index == 10) { + if (current_level_index == LEVEL_ORXON) { menu_item_enabled_68[0] = 1; } } diff --git a/src/overlays/l10/mobys/jitter_strand_grid.c b/src/overlays/l10/mobys/jitter_strand_grid.c index 2b3979e08d..122df8513e 100644 --- a/src/overlays/l10/mobys/jitter_strand_grid.c +++ b/src/overlays/l10/mobys/jitter_strand_grid.c @@ -43,7 +43,7 @@ void jitter_strand_grid_update(struct Moby *moby) { switch (moby->state) { case JITTER_STRAND_GRID_STATE_INITIALIZE: - if (current_level_index == 10 && D_001413F4[0] == 1) { + if (current_level_index == LEVEL_ORXON && D_001413F4[0] == 1) { mark_moby_for_removal(moby); break; } diff --git a/src/overlays/l10/mobys/toxic_crab.c b/src/overlays/l10/mobys/toxic_crab.c index 0c8c002e95..88548bc59c 100644 --- a/src/overlays/l10/mobys/toxic_crab.c +++ b/src/overlays/l10/mobys/toxic_crab.c @@ -1125,7 +1125,7 @@ void update_toxic_crab_hit_reactions_and_targeting(void *mv) { fast_dec_timer_s16(&moby_data->hit_reaction_suppression_timer_frames); if ((unsigned int)A >= 2 && moby->state != TOXIC_CRAB_STATE_DEATH_EFFECTS && moby->state != TOXIC_CRAB_STATE_FALL_TO_DEATH) { - if (current_level_index == 10 && hit_record != 0 && hit_record->f20 != 0 && + if (current_level_index == LEVEL_ORXON && hit_record != 0 && hit_record->f20 != 0 && hit_record->f20->oclass == 0x31A) { if (moby_data->target_range_boost_timer_frames != 0 && item_unlocked[0x11] == 0) { item_unlocked[0x11] = 1; diff --git a/src/overlays/l11/hero/hero_set_state.c b/src/overlays/l11/hero/hero_set_state.c index 847dd324ad..f7208da3b1 100644 --- a/src/overlays/l11/hero/hero_set_state.c +++ b/src/overlays/l11/hero/hero_set_state.c @@ -71,7 +71,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { int old20A7; { struct Hero *p = &hero; - if (p->state.control_mode == 0x14 && + if (p->state.control_mode == HERO_MODE_DYING && (requested_state != HERO_STATE_IDLE_ANIMATION_WITH_DYING_OVERRIDE || animation_update_mode != HERO_ANIMATION_ENTRY_OVERRIDE_GUARDS)) return 0; @@ -81,7 +81,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { return 0; { struct Hero *p = &hero; - if (p->health.hp == 0 && (p->state.control_mode == 2 || p->state.control_mode == 7) && + if (p->health.hp == 0 && + (p->state.control_mode == HERO_MODE_FALL || p->state.control_mode == HERO_MODE_HURT) && requested_state != HERO_STATE_FALL && requested_state != HERO_STATE_DYING && requested_state != HERO_STATE_VEHICLE_MODE_1_DYING && requested_state != HERO_STATE_VEHICLE_MODE_3_DYING && @@ -132,7 +133,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { switch (requested_state) { case HERO_STATE_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; p->unk1010 = random_int_between(scale_game_frames(0x32), scale_game_frames(0x64)); clear_hero_idle_rotation_targets(); @@ -161,7 +162,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_AT_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; clear_u64_value(&p->motion.momentum); p->rand_timer.range = 0x68; @@ -188,7 +189,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (animation_update_mode) @@ -197,7 +198,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DYING_SPEED_LIMITED: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -208,7 +209,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_SINK: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->unk694 = p->motion.displacement.f[2] * 0.2f; @@ -224,11 +225,11 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_SWIM: { struct Hero *p = &hero; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; *(int *)&p->drown_sink_speed = 0; - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } else { @@ -248,11 +249,11 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_SWIM_WITH_CROUCH_INPUT: { struct Hero *p = &hero; int n; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; p->unk8F4 = scale_game_frames(0x3C); - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } @@ -268,7 +269,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_SWIM_IDLE: { struct Hero *p = &hero; int n; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -282,11 +283,11 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_WATER_SURFACE_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; p->splash_effect_timer = 0; - if (p->state.prev_control_mode == 0x11) { + if (p->state.prev_control_mode == HERO_MODE_SWIM) { emit_hero_surface_effect_burst(3, 0xA, 0); if (D_L11_001612D0 != 0) { pool_splash(D_L11_001612D0, @@ -314,7 +315,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { { struct Hero *q = &hero; q->unk698 = 0; - if (q->state.prev_control_mode == 0x11) { + if (q->state.prev_control_mode == HERO_MODE_SWIM) { if ((float)q->underwater_air < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); } else if ((float)q->underwater_air < 7500.0f) { @@ -322,7 +323,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } { struct Hero *r = &hero; - if (r->state.prev_control_mode == 0x11) { + if (r->state.prev_control_mode == HERO_MODE_SWIM) { if ((float)r->underwater_air < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); } else if ((float)r->underwater_air < 7500.0f) { @@ -353,7 +354,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->item_select_blocked = 1; @@ -386,7 +387,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_WATER_SURFACE_MOVE: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; *(int *)&p->drown_sink_speed = 0; @@ -398,7 +399,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DROWN: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -440,7 +441,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DYING_ZERO_HEALTH: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -476,7 +477,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_LOOK: { struct Hero *p = &hero; int t; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 4; *(int *)&D_L11_0015F688 = scale_game_frames(0x3C); if (p->unk20AA == 0) { @@ -489,7 +490,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ITEM_BUTTON_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(0xA)); @@ -498,7 +499,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_WAIT_FOR_ITEM_RELEASE_THEN_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(5)); @@ -507,7 +508,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ITEM_BUTTON_HOLD_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.displacement); p->state.step = 0; @@ -520,9 +521,10 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_DIRECTION_LIMITED_GROUND_MOVE: case HERO_STATE_SHALLOW_WATER_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; - if (p->state.prev_control_mode != 4 && p->state.prev2_control_mode != 4) { + if (p->state.prev_control_mode != HERO_MODE_JUMP && + p->state.prev2_control_mode != HERO_MODE_JUMP) { p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); } { @@ -533,7 +535,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { stick_target(1.0f, 0); if (1.5707964f < fast_difference_between_rotations(q->motion.rot.f[2], q->motion.move_yaw)) { - if (q->state.prev_control_mode == 7 || q->state.prev == 3 || q->state.prev2 == 3) { + if (q->state.prev_control_mode == HERO_MODE_HURT || q->state.prev == 3 || + q->state.prev2 == 3) { struct Hero *r = &hero; r->ground_speed = 0.0f; } @@ -566,7 +569,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { n = scale_game_frames(0x12); { struct Hero *u = &hero; - if (u->state.prev2_control_mode == 4 && + if (u->state.prev2_control_mode == HERO_MODE_JUMP && scale_game_frames(5) < u->rail_land_frames) n = scale_game_frames(0xD); } @@ -580,7 +583,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_APPROACH_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->item_use_locked = 1; @@ -600,7 +603,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_STOP: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (p->on_slip_ground != 0 && p->frames_off_ground.s == 0) { @@ -629,7 +632,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_BRAKE_AT_TARGET_POSITION: { struct Hero *p = &hero; char *v = (char *)&p->motion.resolved_velocity; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = gravity_length_xy((float *)v); qcopy(&p->motion.momentum, v); @@ -644,7 +647,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_CROUCH: { struct Hero *p = &hero; - p->state.control_mode = 0xC; + p->state.control_mode = HERO_MODE_CROUCH; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); if (frame_time * 7.0f < p->ground_speed) @@ -673,7 +676,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_GRAPPLE_TARGET_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -695,7 +698,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_APPROACH_TARGET_MOBY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; *(int *)&p->grapple_pull_speed = 0; p->grapple_pull_ending = 0; @@ -706,7 +709,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_CONSTRAIN_TO_TARGET_RADIUS: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; p->item_use_locked = 1; *(int *)&p->grapple_pull_speed = 0; @@ -719,7 +722,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_GRAPPLE_SWING_ENTRY: { struct Hero *p = &hero; char *d; - p->state.control_mode = 0xE; + p->state.control_mode = HERO_MODE_GRAPPLE_SWING; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -763,9 +766,9 @@ int hero_set_state(int requested_state, int animation_update_mode) { q->swing_target_moby->pos.y - q->motion.pos.f[1]); q->unk9A4 = fast_vec_dist(&q->motion.pos, &q->swing_target_moby->pos); q->swing_gravity = frame_time_sq * 27.0f; - if (q->state.prev_control_mode == 4) { + if (q->state.prev_control_mode == HERO_MODE_JUMP) { q->swing_gravity = q->jump_gravity; - } else if (q->state.prev_control_mode == 2) { + } else if (q->state.prev_control_mode == HERO_MODE_FALL) { q->swing_gravity = q->fall_state_gravity; } if (animation_update_mode) { @@ -780,7 +783,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ITEM_RELEASE_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 7; clear_u64_value(&p->motion.rot_spring_vel); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -802,11 +805,11 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 24.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -822,7 +825,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -832,7 +835,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_LEDGE_SHIMMY_POSITIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (animation_update_mode) @@ -841,7 +844,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_LEDGE_SHIMMY_NEGATIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (animation_update_mode) @@ -850,7 +853,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (animation_update_mode) @@ -860,7 +863,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_FALL: case HERO_STATE_FATAL_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -895,7 +898,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_DELAYED_JUMP_OR_R1_REPEAT_EXIT_WAIT: { struct Hero *p = &hero; int state_81_animation_timing_override = -2; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk22CA = 1; p->rand_timer.range = 0x68; p->unk2284 = 0; @@ -911,7 +914,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_LAND: { struct Hero *p = &hero; int animation_timing_override = -2; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->rand_timer.range = 0x68; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { @@ -949,7 +952,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { p->state_timer = p->state.prev_timer; return 0; } - p->state.control_mode = 4; + p->state.control_mode = HERO_MODE_JUMP; if (requested_state >= HERO_STATE_GRIND_JUMP && requested_state <= HERO_STATE_GRIND_RAIL_TRANSFER) { p->unk2284 = 3; @@ -1242,7 +1245,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } else if (s == 0xA) { set_hero_animation(0x12, 0, (float)scale_game_frames(5)); } else if (s == 0x10) { - if (q->state.prev_control_mode == 4 || + if (q->state.prev_control_mode == HERO_MODE_JUMP || (q->state.prev == 4 && scale_game_frames(7) > q->state_timer)) { set_hero_animation(0x26, 0, (float)scale_game_frames(8)); q->takeoff_frame += scale_game_frames(3); @@ -1274,7 +1277,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } { struct Hero *w = &hero; - if (w->state.prev_control_mode == 4) { + if (w->state.prev_control_mode == HERO_MODE_JUMP) { set_hero_animation(id, 1, (float)scale_game_frames(4)); w->takeoff_frame = scale_game_frames(1); } else { @@ -1293,7 +1296,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_ANIMATION_RECOVERY_WITH_JUMP_CANCEL: case HERO_STATE_VEHICLE_MODE_1_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->speed_scale = 1.0f; p->unk2284 = 0; p->heading_locked = 0; @@ -1392,7 +1395,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { e = &D_L11_0017C628[q->attack_record]; q->saved_item[0] = 0; k = 0; - if (q->state.prev_control_mode == 6 && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { + if (q->state.prev_control_mode == HERO_MODE_ATTACK && e->unk0 == 0 && + q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 3; } { @@ -1478,7 +1482,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_HURT: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->unk1EE = scale_game_frames(0x2D); @@ -1503,7 +1507,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (animation_update_mode) set_hero_animation(0, 0, (float)scale_game_frames(0xE)); @@ -1511,7 +1515,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DELAYED_CIRCLE_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (animation_update_mode) { set_hero_animation(4, 0, (float)scale_game_frames(7)); @@ -1521,7 +1525,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (animation_update_mode) @@ -1530,7 +1534,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1541,7 +1545,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; { char *v = (char *)&p->motion.resolved_velocity; @@ -1559,7 +1563,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (animation_update_mode) @@ -1568,7 +1572,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1584,7 +1588,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_GRIND_COLLISION_RECOVERY: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 0; if (p->rail_off_frames == 0) hero_change_health(1); @@ -1611,7 +1615,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_LOOK_RELEASE_WAIT: { struct Hero *p = &hero; p->unk2284 = 0x51; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; if (return_hero_animation_id_unchanged(p->moby->prev_seq) != get_hero_idle_animation_index(1)) { set_hero_animation(get_hero_idle_animation_index(1), 0, (float)scale_game_frames(5)); @@ -1636,7 +1640,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_IDLE_ANIMATION_LONG_BLEND_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(0xA)); break; @@ -1688,7 +1692,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode != 0xF && t->items[1].item_id == 0x1D && t->saved_item[1] != 0) { + if (t->state.control_mode != HERO_MODE_GRIND && t->items[1].item_id == 0x1D && + t->saved_item[1] != 0) { t->restore_item[1] = 1; } } @@ -1700,7 +1705,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode == 0x14) { + if (t->state.control_mode == HERO_MODE_DYING) { cancel_hero_item_animation(); t->item_use_locked = 1; } diff --git a/src/overlays/l11/hero/update_hero_motion_by_state.c b/src/overlays/l11/hero/update_hero_motion_by_state.c index 9eb7a8745a..e1a6fc78b8 100644 --- a/src/overlays/l11/hero/update_hero_motion_by_state.c +++ b/src/overlays/l11/hero/update_hero_motion_by_state.c @@ -78,7 +78,7 @@ void update_hero_surface_condition_flags(void) { base_condition_hero_ptr = &hero; base_condition_hero_ptr->base_condition = 1; } - if (current_level_index == 0xD) { + if (current_level_index == LEVEL_OLTANIS_ORBIT) { struct Hero *collision_hero_ptr = &hero; if (collision_hero_ptr->state.current != 0x7B) { if (coll_sphere(collision_hero_ptr->capsule_radius + 0.03f, diff --git a/src/overlays/l11/hero/update_hero_state_transitions.c b/src/overlays/l11/hero/update_hero_state_transitions.c index 2bf942585d..7048f89ff5 100644 --- a/src/overlays/l11/hero/update_hero_state_transitions.c +++ b/src/overlays/l11/hero/update_hero_state_transitions.c @@ -148,7 +148,7 @@ void update_hero_state_transitions(void) { prevState = hero.state.step; prevAnim = moby->prev_seq; if (process_hero_hit_response(1) == 0) { - if (hero.health.hp <= 0 && hero.state.control_mode != 0x14 && + if (hero.health.hp <= 0 && hero.state.control_mode != HERO_MODE_DYING && (hero.state.current == HERO_STATE_IDLE || hero.state.current == HERO_STATE_RUN)) { hero_set_state(HERO_STATE_DYING, 1); } else if (process_hero_item_action_input() == 0 && try_enter_hero_water_state() == 0 && @@ -402,7 +402,7 @@ void update_hero_state_transitions(void) { } } if (ok && 0.22f < hero.stick_magnitude) { - if (current_level_index == 0xC) { + if (current_level_index == LEVEL_HOVEN) { int slot = hero.ground_sound_class; request_hero_voice_if_enabled(slot, 0, 0); request_hero_voice_if_enabled(slot, 1, 0); @@ -593,7 +593,8 @@ void update_hero_state_transitions(void) { break; case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: if (hero.health.hp <= 0) { - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || + current_level_index == LEVEL_VELDIN_ORBIT) { hero_set_state(0x82, 1); break; } @@ -782,7 +783,8 @@ void update_hero_state_transitions(void) { break; } if (!(hero.air_frames.s < scale_game_frames(5)) && - !(hero.state.prev_control_mode == 0x12 && hero.wading != 0) && + !(hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE && + hero.wading != 0) && hero.ground_distance > 1.35f) { if (check_hero_forward_collision_height() == 0) { hero_set_state(HERO_STATE_FALL, 1); @@ -842,7 +844,8 @@ void update_hero_state_transitions(void) { } } if (hero.state_timer > scale_game_frames(0xF) || - (hero.state.prev_control_mode != 0 && hero.state.prev_control_mode != 1)) { + (hero.state.prev_control_mode != HERO_MODE_IDLE && + hero.state.prev_control_mode != HERO_MODE_RUN)) { if ((controller_state.pressed & 0x10000) && hero.unk20AA == 0) { hero.unk3BE = 1; } @@ -1348,9 +1351,9 @@ void update_hero_state_transitions(void) { } break; case HERO_STATE_FATAL_FALL: - if ((current_level_index == 3 && 5.0f > hero.motion.pos.f[2]) || - (current_level_index == 6 && 50.0f > hero.motion.pos.f[2]) || - (current_level_index == 0x10 && + if ((current_level_index == LEVEL_KERWAN && 5.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_NEBULA_G34 && 50.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_KALEBO3 && (77.0f > hero.motion.pos.f[2] || (hero.state_timer > 0x14 && hero.wall_hit != 0 && hero.motion.displacement.f[2] >= 0.0f))) || diff --git a/src/overlays/l11/render_sky_shells.c b/src/overlays/l11/render_sky_shells.c index 105b1f49cb..2e02ee6e1e 100644 --- a/src/overlays/l11/render_sky_shells.c +++ b/src/overlays/l11/render_sky_shells.c @@ -11,7 +11,7 @@ void render_sky_shells(void) __asm__("FUN_L11_00263908"); void render_sky_shells(void) { setup_sky_gif_paging(); - if (current_level_index == 0xb) { + if (current_level_index == LEVEL_POKITARU) { draw_sky_shells_with_slow_medium_and_fast_rotation(); } else { update_sky_shells_static(); diff --git a/src/overlays/l12/draw_sky_shells_with_gif_paging.c b/src/overlays/l12/draw_sky_shells_with_gif_paging.c index 5a7c7045ed..7fbc1fccc0 100644 --- a/src/overlays/l12/draw_sky_shells_with_gif_paging.c +++ b/src/overlays/l12/draw_sky_shells_with_gif_paging.c @@ -11,7 +11,7 @@ void draw_sky_shells_with_gif_paging(void) __asm__("FUN_L12_00256748"); void draw_sky_shells_with_gif_paging(void) { setup_sky_gif_paging(); - if (current_level_index == 0xc) { + if (current_level_index == LEVEL_HOVEN) { draw_sky_shells_with_slow_medium_and_fast_rotation(); } else { update_sky_shells_static(); diff --git a/src/overlays/l12/hero/hero_set_state.c b/src/overlays/l12/hero/hero_set_state.c index 25fd725307..ed3f293383 100644 --- a/src/overlays/l12/hero/hero_set_state.c +++ b/src/overlays/l12/hero/hero_set_state.c @@ -72,7 +72,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { int old20A7; { struct Hero *p = &hero; - if (p->state.control_mode == 0x14 && + if (p->state.control_mode == HERO_MODE_DYING && (requested_state != HERO_STATE_IDLE_ANIMATION_WITH_DYING_OVERRIDE || entry_animation_mode != HERO_ANIMATION_ENTRY_OVERRIDE_GUARDS)) return 0; @@ -82,7 +82,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { return 0; { struct Hero *p = &hero; - if (p->health.hp == 0 && (p->state.control_mode == 2 || p->state.control_mode == 7) && + if (p->health.hp == 0 && + (p->state.control_mode == HERO_MODE_FALL || p->state.control_mode == HERO_MODE_HURT) && requested_state != HERO_STATE_FALL && requested_state != HERO_STATE_DYING && requested_state != HERO_STATE_VEHICLE_MODE_1_DYING && requested_state != HERO_STATE_VEHICLE_MODE_3_DYING && @@ -133,7 +134,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { switch (requested_state) { case HERO_STATE_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; p->unk1010 = random_int_between(scale_game_frames(0x32), scale_game_frames(0x64)); clear_hero_idle_rotation_targets(); @@ -168,7 +169,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_AT_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; clear_u64_value(&p->motion.momentum); p->rand_timer.range = 0x68; @@ -194,7 +195,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -203,7 +204,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DYING_SPEED_LIMITED: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -214,7 +215,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_SINK: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->unk694 = p->motion.displacement.f[2] * 0.2f; @@ -230,11 +231,11 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_SWIM: { struct Hero *p = &hero; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; *(int *)&p->drown_sink_speed = 0; - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } else { @@ -254,11 +255,11 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_SWIM_WITH_CROUCH_INPUT: { struct Hero *p = &hero; int n; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; p->unk8F4 = scale_game_frames(0x3C); - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } @@ -274,7 +275,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_SWIM_IDLE: { struct Hero *p = &hero; int n; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -288,11 +289,11 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_WATER_SURFACE_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; p->splash_effect_timer = 0; - if (p->state.prev_control_mode == 0x11) { + if (p->state.prev_control_mode == HERO_MODE_SWIM) { emit_hero_surface_effect_burst(3, 0xA, 0); if (D_L12_001612D0 != 0) { pool_splash(D_L12_001612D0, @@ -320,7 +321,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { { struct Hero *q = &hero; q->unk698 = 0; - if (q->state.prev_control_mode == 0x11) { + if (q->state.prev_control_mode == HERO_MODE_SWIM) { if ((float)q->underwater_air < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); } else if ((float)q->underwater_air < 7500.0f) { @@ -328,7 +329,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *r = &hero; - if (r->state.prev_control_mode == 0x11) { + if (r->state.prev_control_mode == HERO_MODE_SWIM) { if ((float)r->underwater_air < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); } else if ((float)r->underwater_air < 7500.0f) { @@ -359,7 +360,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->item_select_blocked = 1; @@ -392,7 +393,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_WATER_SURFACE_MOVE: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; *(int *)&p->drown_sink_speed = 0; @@ -404,7 +405,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DROWN: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -446,7 +447,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DYING_ZERO_HEALTH: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -482,7 +483,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_LOOK: { struct Hero *p = &hero; int t; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 4; *(int *)&D_L12_0015F688 = scale_game_frames(0x3C); if (p->unk20AA == 0) { @@ -495,7 +496,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ITEM_BUTTON_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(hero_get_gadget_anim_id(0), 0, (float)scale_game_frames(0xA)); @@ -504,7 +505,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_WAIT_FOR_ITEM_RELEASE_THEN_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(hero_get_gadget_anim_id(0), 0, (float)scale_game_frames(5)); @@ -513,7 +514,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ITEM_BUTTON_HOLD_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.displacement); p->state.step = 0; @@ -527,9 +528,10 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_DIRECTION_LIMITED_GROUND_MOVE: case HERO_STATE_SHALLOW_WATER_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; - if (p->state.prev_control_mode != 4 && p->state.prev2_control_mode != 4) { + if (p->state.prev_control_mode != HERO_MODE_JUMP && + p->state.prev2_control_mode != HERO_MODE_JUMP) { p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); } { @@ -540,7 +542,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { stick_target(1.0f, 0); if (1.5707964f < fast_difference_between_rotations(q->motion.rot.f[2], q->motion.move_yaw)) { - if (q->state.prev_control_mode == 7 || q->state.prev == 3 || q->state.prev2 == 3) { + if (q->state.prev_control_mode == HERO_MODE_HURT || q->state.prev == 3 || + q->state.prev2 == 3) { struct Hero *r = &hero; r->ground_speed = 0.0f; } @@ -584,7 +587,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { n = scale_game_frames(0x12); { struct Hero *u = &hero; - if (u->state.prev2_control_mode == 4 && + if (u->state.prev2_control_mode == HERO_MODE_JUMP && scale_game_frames(5) < u->rail_land_frames) n = scale_game_frames(0xD); } @@ -598,7 +601,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ANIMATION_FRAME_EXIT_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; if (entry_animation_mode) { if (p->state.prev == 4) { @@ -611,7 +614,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_APPROACH_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->item_use_locked = 1; @@ -631,7 +634,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_STOP: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (p->on_ice_ground != 0) { @@ -663,7 +666,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_BRAKE_AT_TARGET_POSITION: { struct Hero *p = &hero; char *v = (char *)&p->motion.resolved_velocity; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = gravity_length_xy((float *)v); qcopy(&p->motion.momentum, v); @@ -678,7 +681,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_CROUCH: { struct Hero *p = &hero; - p->state.control_mode = 0xC; + p->state.control_mode = HERO_MODE_CROUCH; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); if (frame_time * 7.0f < p->ground_speed) @@ -707,7 +710,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_GRAPPLE_TARGET_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -729,7 +732,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_APPROACH_TARGET_MOBY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; *(int *)&p->grapple_pull_speed = 0; p->grapple_pull_ending = 0; @@ -740,7 +743,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_CONSTRAIN_TO_TARGET_RADIUS: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; p->item_use_locked = 1; *(int *)&p->grapple_pull_speed = 0; @@ -753,7 +756,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_GRAPPLE_SWING_ENTRY: { struct Hero *p = &hero; char *d; - p->state.control_mode = 0xE; + p->state.control_mode = HERO_MODE_GRAPPLE_SWING; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -797,9 +800,9 @@ int hero_set_state(int requested_state, int entry_animation_mode) { q->swing_target_moby->pos.y - q->motion.pos.f[1]); q->unk9A4 = fast_vec_dist(&q->motion.pos, &q->swing_target_moby->pos); q->swing_gravity = frame_time_sq * 27.0f; - if (q->state.prev_control_mode == 4) { + if (q->state.prev_control_mode == HERO_MODE_JUMP) { q->swing_gravity = q->jump_gravity; - } else if (q->state.prev_control_mode == 2) { + } else if (q->state.prev_control_mode == HERO_MODE_FALL) { q->swing_gravity = q->fall_state_gravity; } if (entry_animation_mode) { @@ -814,7 +817,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ITEM_RELEASE_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 7; clear_u64_value(&p->motion.rot_spring_vel); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -836,11 +839,11 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 24.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -856,7 +859,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -866,7 +869,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_SHIMMY_POSITIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (entry_animation_mode) @@ -875,7 +878,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_SHIMMY_NEGATIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (entry_animation_mode) @@ -884,7 +887,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -894,7 +897,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_FALL: case HERO_STATE_FATAL_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -929,7 +932,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_DELAYED_JUMP_OR_R1_REPEAT_EXIT_WAIT: { struct Hero *p = &hero; int animation_blend_selector = -2; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk22CA = 1; p->rand_timer.range = 0x68; p->unk2284 = 0; @@ -945,7 +948,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_LAND: { struct Hero *p = &hero; int animation_blend_selector = -2; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->rand_timer.range = 0x68; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { @@ -983,7 +986,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { p->state_timer = p->state.prev_timer; return 0; } - p->state.control_mode = 4; + p->state.control_mode = HERO_MODE_JUMP; if (requested_state >= HERO_STATE_GRIND_JUMP && requested_state <= HERO_STATE_GRIND_RAIL_TRANSFER) { p->unk2284 = 3; @@ -1276,7 +1279,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } else if (s == 0xA) { set_hero_animation(0x12, 0, (float)scale_game_frames(5)); } else if (s == 0x10) { - if (q->state.prev_control_mode == 4 || + if (q->state.prev_control_mode == HERO_MODE_JUMP || (q->state.prev == 4 && scale_game_frames(7) > q->state_timer)) { set_hero_animation(0x26, 0, (float)scale_game_frames(8)); q->takeoff_frame += scale_game_frames(3); @@ -1308,7 +1311,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *w = &hero; - if (w->state.prev_control_mode == 4) { + if (w->state.prev_control_mode == HERO_MODE_JUMP) { set_hero_animation(id, 1, (float)scale_game_frames(4)); w->takeoff_frame = scale_game_frames(1); } else { @@ -1327,7 +1330,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_ANIMATION_RECOVERY_WITH_JUMP_CANCEL: case HERO_STATE_VEHICLE_MODE_1_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->speed_scale = 1.0f; p->unk2284 = 0; p->heading_locked = 0; @@ -1426,7 +1429,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { e = &D_L12_0017C0A8[q->attack_record]; q->saved_item[0] = 0; k = 0; - if (q->state.prev_control_mode == 6 && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { + if (q->state.prev_control_mode == HERO_MODE_ATTACK && e->unk0 == 0 && + q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 3; } { @@ -1481,7 +1485,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ATTACK_RECORD_FRAME_EXIT_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unkA64 = 0; if (p->state.prev == 0x70) { int v = 5; @@ -1539,7 +1543,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_HURT: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->unk1EE = scale_game_frames(0x2D); @@ -1564,7 +1568,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (entry_animation_mode) set_hero_animation(0, 0, (float)scale_game_frames(0xE)); @@ -1572,7 +1576,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DELAYED_CIRCLE_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (entry_animation_mode) { set_hero_animation(4, 0, (float)scale_game_frames(7)); @@ -1582,7 +1586,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -1591,7 +1595,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1602,7 +1606,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; { char *v = (char *)&p->motion.resolved_velocity; @@ -1620,7 +1624,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -1629,7 +1633,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1645,7 +1649,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_GRIND_COLLISION_RECOVERY: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 0; if (p->rail_off_frames == 0) hero_change_health(1); @@ -1672,7 +1676,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_LOOK_RELEASE_WAIT: { struct Hero *p = &hero; p->unk2284 = 0x51; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; if (return_hero_animation_id_unchanged(p->moby->prev_seq) != hero_get_gadget_anim_id(1)) { set_hero_animation(hero_get_gadget_anim_id(1), 0, (float)scale_game_frames(5)); } @@ -1696,7 +1700,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_IDLE_ANIMATION_LONG_BLEND_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; set_hero_animation(hero_get_gadget_anim_id(0), 0, (float)scale_game_frames(0xA)); break; @@ -1748,7 +1752,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode != 0xF && t->items[1].item_id == 0x1D && t->saved_item[1] != 0) { + if (t->state.control_mode != HERO_MODE_GRIND && t->items[1].item_id == 0x1D && + t->saved_item[1] != 0) { t->restore_item[1] = 1; } } @@ -1760,7 +1765,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode == 0x14) { + if (t->state.control_mode == HERO_MODE_DYING) { cancel_hero_item_animation(); t->item_use_locked = 1; } diff --git a/src/overlays/l12/hero/update_hero_motion_for_current_state.c b/src/overlays/l12/hero/update_hero_motion_for_current_state.c index c552720a63..57900a5085 100644 --- a/src/overlays/l12/hero/update_hero_motion_for_current_state.c +++ b/src/overlays/l12/hero/update_hero_motion_for_current_state.c @@ -150,7 +150,7 @@ void update_hero_smoothing_targets_and_values(void) { hero.capsule_radius_target = 0.45f; break; } - if (hero.state.control_mode == 4) { + if (hero.state.control_mode == HERO_MODE_JUMP) { if (hero.state_timer > hero.takeoff_frame && hero.past_jump_apex == 0) hero.capsule_bottom_target = hero.unk434; } else if (hero.state.current == HERO_STATE_FALL) { @@ -166,8 +166,8 @@ void update_hero_smoothing_targets_and_values(void) { } else if (hero.state.current == HERO_STATE_SINK) { hero.capsule_radius_target = 0.8f; } - if (!hero.wall_hit || hero.state.prev_control_mode == 0x12 || hero.state.control_mode == 0x11 || - hero.base_condition || + if (!hero.wall_hit || hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE || + hero.state.control_mode == HERO_MODE_SWIM || hero.base_condition || vector_distance_xy(hero.wall_contact_point.f, hero.motion.pos.f) > hero.capsule_radius * 0.5f) { f32 *hero_smoothing_values = D_0013F570; @@ -247,7 +247,7 @@ void update_hero_ground_contact_and_gravity(void) { if (hero.gravity_mode) k = 1; ground_ray_first_endpoint_offset = hero.capsule_radius * 2.2f; - if (hero.state.control_mode == 2) { + if (hero.state.control_mode == HERO_MODE_FALL) { ground_ray_first_endpoint_offset = hero.capsule_radius * 2.9f; } hero_get_collision_ray_endpoints(&ground_ray_first_endpoint, @@ -280,7 +280,7 @@ void update_hero_ground_contact_and_gravity(void) { goto d1; } collision_sound_class = coll_sound_class(); - if (current_level_index == 1 || current_level_index == 0x12) { + if (current_level_index == LEVEL_NOVALIS || current_level_index == LEVEL_VELDIN2) { collision_sound_class = 3; } hero.ground_sound_class = collision_sound_class; @@ -360,9 +360,9 @@ void update_hero_ground_contact_and_gravity(void) { hero.unk2C8.i[1] = 0; hero.unk2C0.i[0] = 0; hero.unk2C0.i[1] = 0; - if (hero.state.control_mode == 0xF || hero.state.control_mode == 0x15 || - hero.state.control_mode == 6 || hero.state.control_mode == 4 || - hero.state.control_mode == 5 || hero.state.control_mode == 3) { + if (hero.state.control_mode == HERO_MODE_GRIND || hero.state.control_mode == 0x15 || + hero.state.control_mode == HERO_MODE_ATTACK || hero.state.control_mode == HERO_MODE_JUMP || + hero.state.control_mode == HERO_MODE_LAND || hero.state.control_mode == HERO_MODE_LEDGE) { return; } if (!(hero.ground_distance < 0.25f)) { diff --git a/src/overlays/l12/hero/update_hero_state_transitions.c b/src/overlays/l12/hero/update_hero_state_transitions.c index 384550da16..afac43eb6b 100644 --- a/src/overlays/l12/hero/update_hero_state_transitions.c +++ b/src/overlays/l12/hero/update_hero_state_transitions.c @@ -149,7 +149,7 @@ void update_hero_state_transitions(void) { prevState = hero.state.step; prevAnim = moby->prev_seq; if (process_hero_hit_response(1) == 0) { - if (hero.health.hp <= 0 && hero.state.control_mode != 0x14 && + if (hero.health.hp <= 0 && hero.state.control_mode != HERO_MODE_DYING && (hero.state.current == HERO_STATE_IDLE || hero.state.current == HERO_STATE_RUN)) { hero_set_state(HERO_STATE_DYING, 1); } else if (process_hero_item_action_input() == 0 && try_enter_hero_water_state() == 0 && @@ -406,7 +406,7 @@ void update_hero_state_transitions(void) { } } if (ok && 0.22f < hero.stick_magnitude) { - if (current_level_index == 0xC) { + if (current_level_index == LEVEL_HOVEN) { int slot = hero.ground_sound_class; emit_hero_animation_voice_and_ground_particle(slot, 0, 0); emit_hero_animation_voice_and_ground_particle(slot, 1, 0); @@ -597,7 +597,8 @@ void update_hero_state_transitions(void) { break; case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: if (hero.health.hp <= 0) { - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || + current_level_index == LEVEL_VELDIN_ORBIT) { hero_set_state(0x82, 1); break; } @@ -786,7 +787,8 @@ void update_hero_state_transitions(void) { break; } if (!(hero.air_frames.s < scale_game_frames(5)) && - !(hero.state.prev_control_mode == 0x12 && hero.wading != 0) && + !(hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE && + hero.wading != 0) && hero.ground_distance > 1.35f) { if (check_hero_forward_collision_height() == 0) { hero_set_state(HERO_STATE_FALL, 1); @@ -877,7 +879,8 @@ void update_hero_state_transitions(void) { hero_set_state(0x3F, 1); } if (hero.state_timer > scale_game_frames(0xF) || - (hero.state.prev_control_mode != 0 && hero.state.prev_control_mode != 1)) { + (hero.state.prev_control_mode != HERO_MODE_IDLE && + hero.state.prev_control_mode != HERO_MODE_RUN)) { if ((controller_state.pressed & 0x10000) && hero.unk20AA == 0) { hero.unk3BE = 1; } @@ -1461,9 +1464,9 @@ void update_hero_state_transitions(void) { } break; case HERO_STATE_FATAL_FALL: - if ((current_level_index == 3 && 5.0f > hero.motion.pos.f[2]) || - (current_level_index == 6 && 50.0f > hero.motion.pos.f[2]) || - (current_level_index == 0x10 && + if ((current_level_index == LEVEL_KERWAN && 5.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_NEBULA_G34 && 50.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_KALEBO3 && (77.0f > hero.motion.pos.f[2] || (hero.state_timer > 0x14 && hero.wall_hit != 0 && hero.motion.displacement.f[2] >= 0.0f))) || diff --git a/src/overlays/l12/mobys/blarg_helicopter.c b/src/overlays/l12/mobys/blarg_helicopter.c index a2cf97bd11..e5c5f3eb8e 100644 --- a/src/overlays/l12/mobys/blarg_helicopter.c +++ b/src/overlays/l12/mobys/blarg_helicopter.c @@ -211,7 +211,7 @@ void blarg_helicopter_update(struct Moby *moby) { blarg_helicopter_vars->unkB0 = -1; } index = blarg_helicopter_vars->unkC0; - if (current_level_index == 12 && D_L12_00161F00 != 0) { + if (current_level_index == LEVEL_HOVEN && D_L12_00161F00 != 0) { if (index == 0) { if (l12_camera.focus_moby == moby) l12_camera.focus_moby = 0; @@ -337,7 +337,7 @@ void blarg_helicopter_update(struct Moby *moby) { case BLARG_HELICOPTER_AIM_AND_FIRE: { int count, limit, a, b, color, life, size; float distance, angle, value, spread; - if (current_level_index == 12 && !D_0013D4CB && !D_00141C50) + if (current_level_index == LEVEL_HOVEN && !D_0013D4CB && !D_00141C50) help_request(0x2ee2, 0x5d); distance = vector_distance_xy(&moby->pos, &hero.motion.pos); if (blarg_helicopter_vars->unkC0 == 0) { diff --git a/src/overlays/l12/mobys/rocket.c b/src/overlays/l12/mobys/rocket.c index d298ad6154..6015d12ce3 100644 --- a/src/overlays/l12/mobys/rocket.c +++ b/src/overlays/l12/mobys/rocket.c @@ -134,7 +134,7 @@ void rocket_update(struct Moby *moby) { moby->state = ROCKET_STATE_DETONATE; break; } - if (current_level_index == 12 && camera_secondary_mode[0] == 50 && + if (current_level_index == LEVEL_HOVEN && camera_secondary_mode[0] == 50 && rocket_state->owner != 0) { if ((signed char)rocket_state->owner->state < 0) { mark_moby_for_removal(moby); @@ -173,7 +173,7 @@ void rocket_update(struct Moby *moby) { if (D_L12_001742C0_lui.moby != 0 && D_L12_001742C0_lui.moby != (int)rocket_state->owner) { damage = 1; - if (current_level_index == 12 && camera_secondary_mode[0] == 50) { + if (current_level_index == LEVEL_HOVEN && camera_secondary_mode[0] == 50) { damage = D_L12_00161F20 >= 16 ? 2 : 3; } make_hit_descriptor(&hit, moby, 0x10003, damage, rocket_state); @@ -197,7 +197,7 @@ void rocket_update(struct Moby *moby) { fast_vec_sub(old_pos, &moby->pos, D_L12_00167240); fast_vec_normalize(old_pos, old_pos, 0.4f); fast_vec_add(&moby->pos, &moby->pos, old_pos); - if (current_level_index == 12 && camera_secondary_mode[0] == 50) { + if (current_level_index == LEVEL_HOVEN && camera_secondary_mode[0] == 50) { char *camera = D_L12_00167240 - 0x140; spawn_explosion(moby, &D_L12_0015F580, diff --git a/src/overlays/l13/draw_paged_sky_shells.c b/src/overlays/l13/draw_paged_sky_shells.c index 10a18e74b7..934fde452d 100644 --- a/src/overlays/l13/draw_paged_sky_shells.c +++ b/src/overlays/l13/draw_paged_sky_shells.c @@ -11,7 +11,7 @@ void draw_paged_sky_shells(void) __asm__("FUN_L13_002497d8"); void draw_paged_sky_shells(void) { setup_sky_gif_paging(); - if (current_level_index == 0xd) { + if (current_level_index == LEVEL_OLTANIS_ORBIT) { draw_three_sky_shells_with_particles(); } else { update_sky_shells_static(); diff --git a/src/overlays/l13/mobys/gemlik_bobbing_pool_tile.c b/src/overlays/l13/mobys/gemlik_bobbing_pool_tile.c index 2a34af1f6a..eb2ca84b0c 100644 --- a/src/overlays/l13/mobys/gemlik_bobbing_pool_tile.c +++ b/src/overlays/l13/mobys/gemlik_bobbing_pool_tile.c @@ -307,7 +307,8 @@ void gemlik_bobbing_pool_tile_update(struct Moby *moby) { (fast_cos(bobbing_platform_vars->angle) * height_half_span_or_tile_enabled + height_half_span_or_tile_enabled); hero_context = &hero; - if (hero_context->state.control_mode != 0x14 && hero_context->state.control_mode != 0x19 && + if (hero_context->state.control_mode != HERO_MODE_DYING && + hero_context->state.control_mode != HERO_MODE_RESPAWN_WAIT && hero_context->state.current != 0x3D && hero_context->state.current != 0x7B && hero_context->state.current != 0x7C) bobbing_platform_vars->angle = diff --git a/src/overlays/l14/hero/hero_set_state.c b/src/overlays/l14/hero/hero_set_state.c index c2f8ffea80..df321e0416 100644 --- a/src/overlays/l14/hero/hero_set_state.c +++ b/src/overlays/l14/hero/hero_set_state.c @@ -71,7 +71,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { float grind_direction_or_jump_reference_position[4]; { struct Hero *p = &hero; - if (p->state.control_mode == 0x14 && + if (p->state.control_mode == HERO_MODE_DYING && (requested_state != HERO_STATE_IDLE_ANIMATION_WITH_DYING_OVERRIDE || animation_update_mode != HERO_ANIMATION_ENTRY_OVERRIDE_GUARDS)) return 0; @@ -81,7 +81,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { return 0; { struct Hero *p = &hero; - if (p->health.hp == 0 && (p->state.control_mode == 2 || p->state.control_mode == 7) && + if (p->health.hp == 0 && + (p->state.control_mode == HERO_MODE_FALL || p->state.control_mode == HERO_MODE_HURT) && requested_state != HERO_STATE_FALL && requested_state != HERO_STATE_DYING && requested_state != HERO_STATE_VEHICLE_MODE_1_DYING && requested_state != HERO_STATE_VEHICLE_MODE_3_DYING && @@ -132,7 +133,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { switch (requested_state) { case HERO_STATE_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; p->unk1010 = random_int_between(scale_game_frames(0x32), scale_game_frames(0x64)); clear_hero_idle_rotation_targets(); @@ -167,7 +168,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_AT_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; clear_u64_value(&p->motion.momentum); p->rand_timer.range = 0x68; @@ -193,7 +194,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (animation_update_mode) @@ -202,7 +203,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DYING_SPEED_LIMITED: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -213,7 +214,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_SINK: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->unk694 = p->motion.displacement.f[2] * 0.2f; @@ -230,7 +231,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_LOOK: { struct Hero *p = &hero; int t; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 4; *(int *)&D_L14_0015F688 = scale_game_frames(0x3C); if (p->unk20AA == 0) { @@ -243,7 +244,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ITEM_BUTTON_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(hero_get_gadget_anim_id(0), 0, (float)scale_game_frames(0xA)); @@ -252,7 +253,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_WAIT_FOR_ITEM_RELEASE_THEN_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(hero_get_gadget_anim_id(0), 0, (float)scale_game_frames(5)); @@ -261,7 +262,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ITEM_BUTTON_HOLD_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.displacement); p->state.step = 0; @@ -275,9 +276,10 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_DIRECTION_LIMITED_GROUND_MOVE: case HERO_STATE_SHALLOW_WATER_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; - if (p->state.prev_control_mode != 4 && p->state.prev2_control_mode != 4) { + if (p->state.prev_control_mode != HERO_MODE_JUMP && + p->state.prev2_control_mode != HERO_MODE_JUMP) { p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); } { @@ -288,7 +290,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { stick_target(1.0f, 0); if (1.5707964f < fast_difference_between_rotations(q->motion.rot.f[2], q->motion.move_yaw)) { - if (q->state.prev_control_mode == 7 || q->state.prev == 3 || q->state.prev2 == 3) { + if (q->state.prev_control_mode == HERO_MODE_HURT || q->state.prev == 3 || + q->state.prev2 == 3) { struct Hero *r = &hero; r->ground_speed = 0.0f; } @@ -329,7 +332,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { n = scale_game_frames(0x12); { struct Hero *u = &hero; - if (u->state.prev2_control_mode == 4 && + if (u->state.prev2_control_mode == HERO_MODE_JUMP && scale_game_frames(5) < u->rail_land_frames) n = scale_game_frames(0xD); } @@ -343,7 +346,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ANIMATION_FRAME_EXIT_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; if (animation_update_mode) { if (p->state.prev == 4) { @@ -356,7 +359,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_APPROACH_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->item_use_locked = 1; @@ -376,7 +379,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_STOP: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (p->on_ice_ground != 0) { @@ -408,7 +411,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_BRAKE_AT_TARGET_POSITION: { struct Hero *p = &hero; char *v = (char *)&p->motion.resolved_velocity; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = gravity_length_xy((float *)v); qcopy(&p->motion.momentum, v); @@ -423,7 +426,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_CROUCH: { struct Hero *p = &hero; - p->state.control_mode = 0xC; + p->state.control_mode = HERO_MODE_CROUCH; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); if (frame_time * 7.0f < p->ground_speed) @@ -452,7 +455,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_GRAPPLE_TARGET_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -474,7 +477,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_APPROACH_TARGET_MOBY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; *(int *)&p->grapple_pull_speed = 0; p->grapple_pull_ending = 0; @@ -485,7 +488,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_CONSTRAIN_TO_TARGET_RADIUS: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; p->item_use_locked = 1; *(int *)&p->grapple_pull_speed = 0; @@ -498,7 +501,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_GRAPPLE_SWING_ENTRY: { struct Hero *p = &hero; char *d; - p->state.control_mode = 0xE; + p->state.control_mode = HERO_MODE_GRAPPLE_SWING; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -542,9 +545,9 @@ int hero_set_state(int requested_state, int animation_update_mode) { q->swing_target_moby->pos.y - q->motion.pos.f[1]); q->unk9A4 = fast_vec_dist(&q->motion.pos, &q->swing_target_moby->pos); q->swing_gravity = frame_time_sq * 27.0f; - if (q->state.prev_control_mode == 4) { + if (q->state.prev_control_mode == HERO_MODE_JUMP) { q->swing_gravity = q->jump_gravity; - } else if (q->state.prev_control_mode == 2) { + } else if (q->state.prev_control_mode == HERO_MODE_FALL) { q->swing_gravity = q->fall_state_gravity; } if (animation_update_mode) { @@ -559,7 +562,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ITEM_RELEASE_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 7; clear_u64_value(&p->motion.rot_spring_vel); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -584,14 +587,14 @@ int hero_set_state(int requested_state, int animation_update_mode) { float pos[4]; int seg; float t; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 3; p->rand_timer.range = 0x68; p->rail_off_frames = 0; p->grind_direction = 1; p->grind_yaw_offset = -1.5707964f; p->grind_anim_variant = 0; - if (p->state.prev_control_mode != 0xF) { + if (p->state.prev_control_mode != HERO_MODE_GRIND) { p->grind_pose = -1; p->unk5AC.i = 0; p->grind_base_speed = 0.0f; @@ -608,7 +611,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { fast_vec_normalize(grind_direction_or_jump_reference_position, grind_direction_or_jump_reference_position, 1.0f); - if (p->state.prev_control_mode != 0xF) { + if (p->state.prev_control_mode != HERO_MODE_GRIND) { p->grind_base_speed = fast_vec_dot(&p->motion.displacement, grind_direction_or_jump_reference_position); } @@ -638,11 +641,11 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 24.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -658,7 +661,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -668,7 +671,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_LEDGE_SHIMMY_POSITIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (animation_update_mode) @@ -677,7 +680,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_LEDGE_SHIMMY_NEGATIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (animation_update_mode) @@ -686,7 +689,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (animation_update_mode) @@ -696,7 +699,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_FALL: case HERO_STATE_FATAL_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -731,7 +734,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_DELAYED_JUMP_OR_R1_REPEAT_EXIT_WAIT: { struct Hero *p = &hero; int animation_timing_preset_selector = -2; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk22CA = 1; p->rand_timer.range = 0x68; p->unk2284 = 0; @@ -747,7 +750,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_LAND: { struct Hero *p = &hero; int animation_timing_selector = -2; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->rand_timer.range = 0x68; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { @@ -785,7 +788,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { p->state_timer = p->state.prev_timer; return 0; } - p->state.control_mode = 4; + p->state.control_mode = HERO_MODE_JUMP; if (requested_state >= HERO_STATE_GRIND_JUMP && requested_state <= HERO_STATE_GRIND_RAIL_TRANSFER) { p->unk2284 = 3; @@ -854,7 +857,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { u->unk48C = 2.45f; u->jump_height_start = 2.4f; u->unk498 = scale_game_frames(0x11); - u->state.control_mode = 0xF; + u->state.control_mode = HERO_MODE_GRIND; u->rail_gap_jump = 0; u->jump_gravity = frame_time_sq * 27.0f; if (u->selector_5 != 0) { @@ -885,7 +888,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { u->unk48C = 2.55f; u->jump_height_start = 2.5f; u->unk498 = scale_game_frames(0xA); - u->state.control_mode = 0xF; + u->state.control_mode = HERO_MODE_GRIND; u->rail_gap_jump = 0; u->jump_gravity = frame_time_sq * 24.0f; } else if (u->state.current == 9) { @@ -1101,7 +1104,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } else if (s == 0xA) { set_hero_animation(0x12, 0, (float)scale_game_frames(5)); } else if (s == 0x10) { - if (q->state.prev_control_mode == 4 || + if (q->state.prev_control_mode == HERO_MODE_JUMP || (q->state.prev == 4 && scale_game_frames(7) > q->state_timer)) { set_hero_animation(0x26, 0, (float)scale_game_frames(8)); q->takeoff_frame += scale_game_frames(3); @@ -1133,7 +1136,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } { struct Hero *w = &hero; - if (w->state.prev_control_mode == 4) { + if (w->state.prev_control_mode == HERO_MODE_JUMP) { set_hero_animation(id, 1, (float)scale_game_frames(4)); w->takeoff_frame = scale_game_frames(1); } else { @@ -1152,7 +1155,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_ANIMATION_RECOVERY_WITH_JUMP_CANCEL: case HERO_STATE_VEHICLE_MODE_1_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->speed_scale = 1.0f; p->unk2284 = 0; p->heading_locked = 0; @@ -1252,7 +1255,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { e = &D_L14_0017C328[q->attack_record]; q->saved_item[0] = 0; k = 0; - if (q->state.prev_control_mode == 6 && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { + if (q->state.prev_control_mode == HERO_MODE_ATTACK && e->unk0 == 0 && + q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 3; } { @@ -1307,7 +1311,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ATTACK_RECORD_FRAME_EXIT_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unkA64 = 0; if (p->state.prev == 0x70) { int v = 5; @@ -1334,7 +1338,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_GRIND_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unkA64 = 0; if (p->state.prev == 0x2B) { p->attack_record = p->attack_record == 0; @@ -1385,7 +1389,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_HURT: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->unk1EE = scale_game_frames(0x2D); @@ -1410,7 +1414,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (animation_update_mode) set_hero_animation(0, 0, (float)scale_game_frames(0xE)); @@ -1418,7 +1422,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DELAYED_CIRCLE_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (animation_update_mode) { set_hero_animation(4, 0, (float)scale_game_frames(7)); @@ -1428,7 +1432,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (animation_update_mode) @@ -1437,7 +1441,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1448,7 +1452,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; { char *v = (char *)&p->motion.resolved_velocity; @@ -1466,7 +1470,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (animation_update_mode) @@ -1475,7 +1479,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1491,7 +1495,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_GRIND_COLLISION_RECOVERY: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 0; if (p->rail_off_frames == 0) hero_change_health(1); @@ -1518,7 +1522,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_LOOK_RELEASE_WAIT: { struct Hero *p = &hero; p->unk2284 = 0x51; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; if (return_hero_animation_id_unchanged(p->moby->prev_seq) != hero_get_gadget_anim_id(1)) { set_hero_animation(hero_get_gadget_anim_id(1), 0, (float)scale_game_frames(5)); } @@ -1542,7 +1546,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_IDLE_ANIMATION_LONG_BLEND_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; set_hero_animation(hero_get_gadget_anim_id(0), 0, (float)scale_game_frames(0xA)); break; @@ -1594,7 +1598,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode != 0xF && t->items[1].item_id == 0x1D && t->saved_item[1] != 0) { + if (t->state.control_mode != HERO_MODE_GRIND && t->items[1].item_id == 0x1D && + t->saved_item[1] != 0) { t->restore_item[1] = 1; } } @@ -1606,7 +1611,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode == 0x14) { + if (t->state.control_mode == HERO_MODE_DYING) { cancel_hero_item_animation(); t->item_use_locked = 1; } diff --git a/src/overlays/l14/hero/process_hero_state_transitions.c b/src/overlays/l14/hero/process_hero_state_transitions.c index 986b3efc40..af7631353a 100644 --- a/src/overlays/l14/hero/process_hero_state_transitions.c +++ b/src/overlays/l14/hero/process_hero_state_transitions.c @@ -167,7 +167,7 @@ void process_hero_state_transitions(void) { prevState = hero.state.step; prevAnim = MOBY(moby)->prev_seq; if (process_hero_hit_reaction(1) == 0) { - if (hero.health.hp <= 0 && hero.state.control_mode != 0x14 && + if (hero.health.hp <= 0 && hero.state.control_mode != HERO_MODE_DYING && (hero.state.current == HERO_STATE_IDLE || hero.state.current == HERO_STATE_RUN)) { hero_set_state(HERO_STATE_DYING, 1); } else if (process_hero_item_action_input() == 0 && @@ -431,7 +431,7 @@ void process_hero_state_transitions(void) { } } if (ok && 0.22f < hero.stick_magnitude) { - if (current_level_index == 0xC) { + if (current_level_index == LEVEL_HOVEN) { int slot = hero.ground_sound_class; emit_hero_animation_voice_and_ground_particle(slot, 0, 0); emit_hero_animation_voice_and_ground_particle(slot, 1, 0); @@ -659,7 +659,8 @@ void process_hero_state_transitions(void) { break; } if (!(hero.air_frames.s < scale_game_frames(5)) && - !(hero.state.prev_control_mode == 0x12 && hero.wading != 0) && + !(hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE && + hero.wading != 0) && hero.ground_distance > 1.35f) { if (check_hero_forward_collision_height() == 0) { hero_set_state(HERO_STATE_FALL, 1); @@ -746,7 +747,8 @@ void process_hero_state_transitions(void) { break; } if (hero.state_timer > scale_game_frames(0xF) || - (hero.state.prev_control_mode != 0 && hero.state.prev_control_mode != 1)) { + (hero.state.prev_control_mode != HERO_MODE_IDLE && + hero.state.prev_control_mode != HERO_MODE_RUN)) { if ((controller_state.pressed & 0x10000) && hero.unk20AA == 0) { hero.unk3BE = 1; } @@ -1100,7 +1102,7 @@ void process_hero_state_transitions(void) { float len; grab = 0; - if (current_level_index == 0x10 && hero.wall_hit != 0) { + if (current_level_index == LEVEL_KALEBO3 && hero.wall_hit != 0) { unsigned char *m = ((unsigned char *)hero.coll_hit_moby); if (m != 0 && *(short *)(m + 0xA6) == 0x101) { grab = 1; @@ -1112,7 +1114,7 @@ void process_hero_state_transitions(void) { hero.unk5BE != 0) { int ok = 1; - if (current_level_index != 0x10) { + if (current_level_index != LEVEL_KALEBO3) { qcopy(query_position, hero.rail_point.f); query_position[2] += 2.0f; motion_query_vector[0] = fast_cos(hero.rail_dir_yaw) * 5.0f; @@ -1163,7 +1165,7 @@ void process_hero_state_transitions(void) { if (hero.state.current == HERO_STATE_GRIND) { int go = 1; - if (current_level_index == 8) { + if (current_level_index == LEVEL_BATALIA) { *(OvlQuad *)query_position = 0; query_position[0] = 342.0f; query_position[1] = 111.1f; @@ -1667,9 +1669,9 @@ void process_hero_state_transitions(void) { } break; case HERO_STATE_FATAL_FALL: - if ((current_level_index == 3 && 5.0f > hero.motion.pos.f[2]) || - (current_level_index == 6 && 50.0f > hero.motion.pos.f[2]) || - (current_level_index == 0x10 && + if ((current_level_index == LEVEL_KERWAN && 5.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_NEBULA_G34 && 50.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_KALEBO3 && (77.0f > hero.motion.pos.f[2] || (hero.state_timer > 0x14 && hero.wall_hit != 0 && hero.motion.displacement.f[2] >= 0.0f))) || @@ -2175,8 +2177,8 @@ void process_hero_state_transitions(void) { hero_set_state(HERO_STATE_FALL, 1); break; } - if (current_level_index == 0x10 && hero.motion.velocity.f[2] < 0.0f && - hero.health.hp == 0 && hero.state.prev_control_mode == 0xF) { + if (current_level_index == LEVEL_KALEBO3 && hero.motion.velocity.f[2] < 0.0f && + hero.health.hp == 0 && hero.state.prev_control_mode == HERO_MODE_GRIND) { hero_set_state(0x77, 1); break; } diff --git a/src/overlays/l14/hero/update_hero_motion_by_state.c b/src/overlays/l14/hero/update_hero_motion_by_state.c index ed2b8070de..20bca8aec9 100644 --- a/src/overlays/l14/hero/update_hero_motion_by_state.c +++ b/src/overlays/l14/hero/update_hero_motion_by_state.c @@ -65,7 +65,7 @@ void resolve_hero_surface_reactions(void) { } } } - if (current_level_index == 0xD) { + if (current_level_index == LEVEL_OLTANIS_ORBIT) { struct Hero *q = &hero; if (q->state.current != 0x7B) { if (coll_sphere(q->capsule_radius + 0.03f, &q->motion.body_center, 2, 0)) { @@ -148,10 +148,10 @@ s32 process_hero_hit_reaction(s32 apply_hit_reaction) { f32 horizontal_knockback_scale, vertical_knockback_scale, knockback_scale; OvlVec4 knockback_impulse; - if (G.state.control_mode == 0x14) { + if (G.state.control_mode == HERO_MODE_DYING) { return 0; } - if (G.state.control_mode == 7) { + if (G.state.control_mode == HERO_MODE_HURT) { return 0; } if (G.state.current == 0x32) { @@ -178,7 +178,7 @@ s32 process_hero_hit_reaction(s32 apply_hit_reaction) { D_0013DF88[current_level_index]++; G.damage_source_moby = (struct Moby *)hero_hit_entry->target; D_0015EEA8++; - if (G.state.control_mode == 0xF) { + if (G.state.control_mode == HERO_MODE_GRIND) { G.unk5BE = 1; return 0; } @@ -257,7 +257,7 @@ void update_hero_smoothed_parameters(void) { hero.capsule_radius_target = 0.45f; break; } - if (hero.state.control_mode == 4) { + if (hero.state.control_mode == HERO_MODE_JUMP) { if (hero.state_timer > hero.takeoff_frame && hero.past_jump_apex == 0) hero.capsule_bottom_target = hero.unk434; } else if (hero.state.current == HERO_STATE_FALL) { @@ -270,8 +270,8 @@ void update_hero_smoothed_parameters(void) { } else if (hero.state.current == HERO_STATE_SINK) { hero.capsule_radius_target = 0.8f; } - if (!hero.wall_hit || hero.state.prev_control_mode == 0x12 || hero.state.control_mode == 0x11 || - hero.base_condition || + if (!hero.wall_hit || hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE || + hero.state.control_mode == HERO_MODE_SWIM || hero.base_condition || vector_distance_xy(hero.wall_contact_point.f, hero.motion.pos.f) > hero.capsule_radius * 0.5f) { f32 *smoothed_values = D_0013F570; diff --git a/src/overlays/l14/mobys/bolt_thief.c b/src/overlays/l14/mobys/bolt_thief.c index 92be37570e..d0526b35a1 100644 --- a/src/overlays/l14/mobys/bolt_thief.c +++ b/src/overlays/l14/mobys/bolt_thief.c @@ -346,7 +346,7 @@ int update_bolt_thief_path_movement(struct Moby *moby) { float path_sample_step = bolt_thief_default_path_sample_rate_gp * frame_time; int path_sample_result; char *path; - if (current_level_index == 0x10) + if (current_level_index == LEVEL_KALEBO3) path_sample_step = frame_time * 20.0f; if (bolt_thief_state->unkF8 != 0.0f) path_sample_step = bolt_thief_state->unkF8 * frame_time; diff --git a/src/overlays/l14/mobys/cutscene_effects.c b/src/overlays/l14/mobys/cutscene_effects.c index 238ce87194..cd1122b0ed 100644 --- a/src/overlays/l14/mobys/cutscene_effects.c +++ b/src/overlays/l14/mobys/cutscene_effects.c @@ -11,7 +11,7 @@ void update_level14_cutscene_effects(void) __asm__("FUN_L14_002460f8"); void update_level14_cutscene_effects(void) { void *moby; - if (current_level_index != 14 || D_L14_0016CF60.scene != 0) { + if (current_level_index != LEVEL_OLTANIS || D_L14_0016CF60.scene != 0) { return; } moby = D_L14_0016CF60.scene_mobys[1]; diff --git a/src/overlays/l14/mobys/enemy_fighter.c b/src/overlays/l14/mobys/enemy_fighter.c index db2f24af00..4e644294be 100644 --- a/src/overlays/l14/mobys/enemy_fighter.c +++ b/src/overlays/l14/mobys/enemy_fighter.c @@ -75,7 +75,7 @@ void enemy_fighter_update(struct Moby *moby) { char *path; moby->hit_slot = 0xff; if (hit && moby->state != ENEMY_FIGHTER_STATE_WAIT_FOR_RESPAWN) { - if (current_level_index == 14) { + if (current_level_index == LEVEL_OLTANIS) { enemy_fighter_destruction_count = enemy_fighter_destruction_count + 1; if (enemy_fighter_destruction_count > 2 && D_0013D408.flag == 0) { D_0013D408.flag = 1; diff --git a/src/overlays/l14/mobys/flying_car.c b/src/overlays/l14/mobys/flying_car.c index 98432d7eef..f167a08e0b 100644 --- a/src/overlays/l14/mobys/flying_car.c +++ b/src/overlays/l14/mobys/flying_car.c @@ -226,8 +226,9 @@ void flying_car_update(struct Moby *flying_car_moby) { &flying_car_moby->rot_row2, flying_car_data->fAC); fast_vec_add(&o->pos, &o->pos, &attached_part_offset_component); - if ((hero.state.control_mode == 13 && hero.grapple_target == o) || - (hero.state.control_mode == 14 && hero.swing_target_moby == o)) { + if ((hero.state.control_mode == HERO_MODE_GRAPPLE && hero.grapple_target == o) || + (hero.state.control_mode == HERO_MODE_GRAPPLE_SWING && + hero.swing_target_moby == o)) { seed_linked_record_for_flying_car(flying_car_moby); flying_car_data->fCC = scale_game_frames(0x1E); } else { @@ -381,7 +382,8 @@ int update_flying_car_path_motion(struct Moby *moby) { if (((unsigned)(hero.state.current - 0x25) < 2 && *(int *)(flying_car_data + 0xA0) >= 0 && hero.grapple_target == (struct Moby *)(D_L14_0015FFD8_7620 + *(int *)(flying_car_data + 0xA0) * 256)) || - (hero.state.control_mode == 0xE && *(int *)(flying_car_data + 0xA0) >= 0 && + (hero.state.control_mode == HERO_MODE_GRAPPLE_SWING && + *(int *)(flying_car_data + 0xA0) >= 0 && hero.swing_target_moby == (struct Moby *)(D_L14_0015FFD8_7620 + *(int *)(flying_car_data + 0xA0) * 256))) { float lim; diff --git a/src/overlays/l14/mobys/path_lightning_controller.c b/src/overlays/l14/mobys/path_lightning_controller.c index db67a3f552..ad50cc931c 100644 --- a/src/overlays/l14/mobys/path_lightning_controller.c +++ b/src/overlays/l14/mobys/path_lightning_controller.c @@ -67,7 +67,7 @@ void path_lightning_controller_update(struct Moby *moby) { float visibility_test_point[4]; int moby_state; if (MOBY(moby)->state == PATH_LIGHTNING_STATE_INITIALIZE) { - if (current_level_index == 0xE) + if (current_level_index == LEVEL_OLTANIS) hero.pack_disabled = 1; MOBY(moby)->state = PATH_LIGHTNING_STATE_WAIT_SCENE_START; moby->update_dist = 0xFF; diff --git a/src/overlays/l14/mobys/ribbon_effect.c b/src/overlays/l14/mobys/ribbon_effect.c index adbc8e3d44..e7d76ad974 100644 --- a/src/overlays/l14/mobys/ribbon_effect.c +++ b/src/overlays/l14/mobys/ribbon_effect.c @@ -56,7 +56,7 @@ void ribbon_effect_moby_update(struct Moby *moby) { break; case MOBY_STATE_UPDATE: x = &hero; - if (x->state.control_mode != 0xF || + if (x->state.control_mode != HERO_MODE_GRIND || (x->rail_spline != (int)l14_splines[*(int *)(ribbon_effect_state + 0x1F4)].path && x->rail_spline != (int)l14_splines[*(int *)(ribbon_effect_state + 0x1F8)].path && x->rail_spline != (int)l14_splines[*(int *)(ribbon_effect_state + 0x1FC)].path)) { diff --git a/src/overlays/l14/mobys/rocket_strike_fighter.c b/src/overlays/l14/mobys/rocket_strike_fighter.c index 7122e56c2e..d76e9f6481 100644 --- a/src/overlays/l14/mobys/rocket_strike_fighter.c +++ b/src/overlays/l14/mobys/rocket_strike_fighter.c @@ -112,7 +112,7 @@ void rocket_strike_fighter_update(struct Moby *moby) { moby->hit_slot = 0xFF; if (hit != 0 && moby_vars->rocket == -1 && moby->state != ROCKET_STRIKE_FIGHTER_STATE_WAIT_FOR_RESPAWN) { - if (current_level_index == 14) { + if (current_level_index == LEVEL_OLTANIS) { enemy_fighter_destruction_count = enemy_fighter_destruction_count + 1; if (enemy_fighter_destruction_count >= 3 && item_unlocked[0x18] == 0) { item_unlocked[0x18] = 1; diff --git a/src/overlays/l14/mobys/shuttle.c b/src/overlays/l14/mobys/shuttle.c index 94541ccab8..4596756a18 100644 --- a/src/overlays/l14/mobys/shuttle.c +++ b/src/overlays/l14/mobys/shuttle.c @@ -139,7 +139,7 @@ void shuttle_update(struct Moby *shuttle_moby) { build_axis_rotation_quaternion(shuttle_vars->wobble, 0, shuttle_vars->angle); fast_vec_sub(&delta, &shuttle_moby->pos, &previous_shuttle_position); update_entity_matrix(shuttle_vars->spring, &delta, &rot, &shuttle_moby->rot); - if (hero.state.control_mode == 13 && hero.grapple_target == rider) { + if (hero.state.control_mode == HERO_MODE_GRAPPLE && hero.grapple_target == rider) { if (shuttle_vars->riding == 0) { shuttle_vars->riding = 1; shuttle_vars->timer = scale_game_frames(shuttle_enter_riding_transition_frames_gp); diff --git a/src/overlays/l14/path_camera.c b/src/overlays/l14/path_camera.c index 28b716cd23..92a33259d8 100644 --- a/src/overlays/l14/path_camera.c +++ b/src/overlays/l14/path_camera.c @@ -119,7 +119,7 @@ void setup_path_camera(char *camera) { *(float *)(camera_saved_state + 0x20) = 0.03f; *(float *)(camera_saved_state + 0x24) = 0.2f; clear_u64_value(camera_saved_state + 0x30); - initial_camera_transform = l14_camera.unk184; + initial_camera_transform = l14_camera.previous_camera; qcopy(camera + 0x30, initial_camera_transform + 0x30); qcopy(camera, initial_camera_transform); qcopy(camera + 0x10, initial_camera_transform + 0x10); @@ -307,7 +307,7 @@ int check_path_camera_priority(char *camera, char *control_mode_gate_object) { if (*(unsigned char *)(path_camera_priority_preset + 0x38) != 0) return -1; if (control_mode_gate_object != 0 && *(short *)(control_mode_gate_object + 0x7E) == 0) { - if (hero.state.control_mode != 15) + if (hero.state.control_mode != HERO_MODE_GRIND) return 0; } if (check_descriptor_hero_trigger(camera) == 0) diff --git a/src/overlays/l14/render_sky_shells_with_gif_paging.c b/src/overlays/l14/render_sky_shells_with_gif_paging.c index 529805957d..78df305f61 100644 --- a/src/overlays/l14/render_sky_shells_with_gif_paging.c +++ b/src/overlays/l14/render_sky_shells_with_gif_paging.c @@ -11,7 +11,7 @@ void render_sky_shells_with_gif_paging(void) __asm__("FUN_L14_00245940"); void render_sky_shells_with_gif_paging(void) { setup_sky_gif_paging(); - if (current_level_index == 0xe) { + if (current_level_index == LEVEL_OLTANIS) { draw_three_sky_shells_with_modulo_50000_and_100000_rotation(); } else { update_sky_shells_static(); diff --git a/src/overlays/l15/draw_sky_shells_with_gif_paging.c b/src/overlays/l15/draw_sky_shells_with_gif_paging.c index c701a54755..5e4f5794c6 100644 --- a/src/overlays/l15/draw_sky_shells_with_gif_paging.c +++ b/src/overlays/l15/draw_sky_shells_with_gif_paging.c @@ -11,7 +11,7 @@ void draw_sky_shells_with_gif_paging(void) __asm__("FUN_L15_0022dad0"); void draw_sky_shells_with_gif_paging(void) { setup_sky_gif_paging(); - if (current_level_index == 0xf) { + if (current_level_index == LEVEL_QUARTU) { draw_two_sky_shells_with_particles(); } else { update_sky_shells_static(); diff --git a/src/overlays/l15/hero/hero_set_state.c b/src/overlays/l15/hero/hero_set_state.c index 2d50fb0f00..3479dc4d68 100644 --- a/src/overlays/l15/hero/hero_set_state.c +++ b/src/overlays/l15/hero/hero_set_state.c @@ -74,7 +74,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { int old20A7; { struct Hero *p = &hero; - if (p->state.control_mode == 0x14 && + if (p->state.control_mode == HERO_MODE_DYING && (requested_state != HERO_STATE_IDLE_ANIMATION_WITH_DYING_OVERRIDE || entry_animation_mode != HERO_ANIMATION_ENTRY_OVERRIDE_GUARDS)) return 0; @@ -84,7 +84,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { return 0; { struct Hero *p = &hero; - if (p->health.hp == 0 && (p->state.control_mode == 2 || p->state.control_mode == 7) && + if (p->health.hp == 0 && + (p->state.control_mode == HERO_MODE_FALL || p->state.control_mode == HERO_MODE_HURT) && requested_state != HERO_STATE_FALL && requested_state != HERO_STATE_DYING && requested_state != HERO_STATE_VEHICLE_MODE_1_DYING && requested_state != HERO_STATE_VEHICLE_MODE_3_DYING && @@ -135,7 +136,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { switch (requested_state) { case HERO_STATE_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; p->unk1010 = random_int_between(scale_game_frames(0x32), scale_game_frames(0x64)); clear_hero_idle_rotation_targets(); @@ -163,7 +164,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_AT_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; clear_u64_value(&p->motion.momentum); p->rand_timer.range = 0x68; @@ -189,7 +190,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -198,11 +199,11 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_SWIM: { struct Hero *p = &hero; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; *(int *)&p->drown_sink_speed = 0; - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } else { @@ -222,11 +223,11 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_SWIM_WITH_CROUCH_INPUT: { struct Hero *p = &hero; int n; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; p->unk8F4 = scale_game_frames(0x3C); - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } @@ -243,7 +244,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { struct Hero *p = &hero; int n; int t; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -258,11 +259,11 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_WATER_SURFACE_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; p->splash_effect_timer = 0; - if (p->state.prev_control_mode == 0x11) { + if (p->state.prev_control_mode == HERO_MODE_SWIM) { emit_hero_surface_effect_burst(3, 0xA, 0); if (D_L15_001612D0 != 0) { pool_splash(D_L15_001612D0, @@ -293,7 +294,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { { struct Hero *q = &hero; q->unk698 = 0; - if (q->state.prev_control_mode == 0x11) { + if (q->state.prev_control_mode == HERO_MODE_SWIM) { float d = (float)q->underwater_air; if (d < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); @@ -302,7 +303,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *r = &hero; - if (r->state.prev_control_mode == 0x11) { + if (r->state.prev_control_mode == HERO_MODE_SWIM) { float e = (float)r->underwater_air; if (e < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); @@ -334,7 +335,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->item_select_blocked = 1; @@ -366,7 +367,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_WATER_SURFACE_MOVE: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; *(int *)&p->drown_sink_speed = 0; @@ -378,7 +379,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DROWN: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -418,7 +419,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DYING_ZERO_HEALTH: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -430,7 +431,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_LOOK: { struct Hero *p = &hero; int t; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 4; *(int *)&D_L15_0015F688 = scale_game_frames(0x3C); if (p->unk20AA == 0) { @@ -443,7 +444,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ITEM_BUTTON_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_help_value(0), 0, (float)scale_game_frames(0xA)); @@ -452,7 +453,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_WAIT_FOR_ITEM_RELEASE_THEN_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_help_value(0), 0, (float)scale_game_frames(5)); @@ -461,7 +462,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ITEM_BUTTON_HOLD_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.displacement); p->state.step = 0; @@ -474,9 +475,10 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_DIRECTION_LIMITED_GROUND_MOVE: case HERO_STATE_SHALLOW_WATER_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; - if (p->state.prev_control_mode != 4 && p->state.prev2_control_mode != 4) { + if (p->state.prev_control_mode != HERO_MODE_JUMP && + p->state.prev2_control_mode != HERO_MODE_JUMP) { p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); } { @@ -487,7 +489,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { stick_target(1.0f, 0); if (1.5707964f < fast_difference_between_rotations(q->motion.rot.f[2], q->motion.move_yaw)) { - if (q->state.prev_control_mode == 7 || q->state.prev == 3 || q->state.prev2 == 3) { + if (q->state.prev_control_mode == HERO_MODE_HURT || q->state.prev == 3 || + q->state.prev2 == 3) { struct Hero *r = &hero; r->ground_speed = 0.0f; } @@ -520,7 +523,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { n = scale_game_frames(0x12); { struct Hero *u = &hero; - if (u->state.prev2_control_mode == 4 && + if (u->state.prev2_control_mode == HERO_MODE_JUMP && scale_game_frames(5) < u->rail_land_frames) n = scale_game_frames(0xD); } @@ -534,7 +537,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_APPROACH_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->item_use_locked = 1; @@ -565,7 +568,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_STOP: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (p->on_slip_ground != 0 && p->frames_off_ground.s == 0) { @@ -593,7 +596,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_BRAKE_AT_TARGET_POSITION: { struct Hero *p = &hero; char *v = (char *)&p->motion.resolved_velocity; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = gravity_length_xy((float *)v); qcopy(&p->motion.momentum, v); @@ -608,7 +611,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_CROUCH: { struct Hero *p = &hero; - p->state.control_mode = 0xC; + p->state.control_mode = HERO_MODE_CROUCH; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); if (frame_time * 7.0f < p->ground_speed) @@ -637,7 +640,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_GRAPPLE_TARGET_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -659,7 +662,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_APPROACH_TARGET_MOBY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; *(int *)&p->grapple_pull_speed = 0; p->grapple_pull_ending = 0; @@ -670,7 +673,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_CONSTRAIN_TO_TARGET_RADIUS: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; p->item_use_locked = 1; *(int *)&p->grapple_pull_speed = 0; @@ -683,7 +686,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_GRAPPLE_SWING_ENTRY: { struct Hero *p = &hero; char *d; - p->state.control_mode = 0xE; + p->state.control_mode = HERO_MODE_GRAPPLE_SWING; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -727,9 +730,9 @@ int hero_set_state(int requested_state, int entry_animation_mode) { q->swing_target_moby->pos.y - q->motion.pos.f[1]); q->unk9A4 = fast_vec_dist(&q->motion.pos, &q->swing_target_moby->pos); q->swing_gravity = frame_time_sq * 27.0f; - if (q->state.prev_control_mode == 4) { + if (q->state.prev_control_mode == HERO_MODE_JUMP) { q->swing_gravity = q->jump_gravity; - } else if (q->state.prev_control_mode == 2) { + } else if (q->state.prev_control_mode == HERO_MODE_FALL) { q->swing_gravity = q->fall_state_gravity; } if (entry_animation_mode) { @@ -744,7 +747,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_ITEM_RELEASE_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 7; clear_u64_value(&p->motion.rot_spring_vel); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -766,11 +769,11 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 24.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -786,7 +789,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -796,7 +799,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_SHIMMY_POSITIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (entry_animation_mode) @@ -805,7 +808,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_LEDGE_SHIMMY_NEGATIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (entry_animation_mode) @@ -814,7 +817,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -824,7 +827,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_FALL: case HERO_STATE_FATAL_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -859,7 +862,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_DELAYED_JUMP_OR_R1_REPEAT_EXIT_WAIT: { struct Hero *p = &hero; int animation_blend_selector = -2; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk22CA = 1; p->rand_timer.range = 0x68; p->unk2284 = 0; @@ -875,7 +878,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_LAND: { struct Hero *p = &hero; int animation_blend_selector = -2; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->rand_timer.range = 0x68; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { @@ -913,7 +916,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { p->state_timer = p->state.prev_timer; return 0; } - p->state.control_mode = 4; + p->state.control_mode = HERO_MODE_JUMP; if (requested_state >= HERO_STATE_GRIND_JUMP && requested_state <= HERO_STATE_GRIND_RAIL_TRANSFER) { p->unk2284 = 3; @@ -1006,7 +1009,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } } else if (u->state.current == 0x69) { float v; - u->state.control_mode = 0x19; + u->state.control_mode = HERO_MODE_RESPAWN_WAIT; if (u->motion.pos.f[2] < u->sink_surface_z) { v = u->sink_surface_z - u->motion.pos.f[2]; } else { @@ -1247,7 +1250,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } else if (s == 0xA) { set_hero_animation(0x12, 0, (float)scale_game_frames(5)); } else if (s == 0x10) { - if (q->state.prev_control_mode == 4 || + if (q->state.prev_control_mode == HERO_MODE_JUMP || (q->state.prev == 4 && scale_game_frames(7) > q->state_timer)) { set_hero_animation(0x26, 0, (float)scale_game_frames(8)); q->takeoff_frame += scale_game_frames(3); @@ -1279,7 +1282,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *w = &hero; - if (w->state.prev_control_mode == 4) { + if (w->state.prev_control_mode == HERO_MODE_JUMP) { set_hero_animation(id, 1, (float)scale_game_frames(4)); w->takeoff_frame = scale_game_frames(1); } else { @@ -1298,7 +1301,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_ANIMATION_RECOVERY_WITH_JUMP_CANCEL: case HERO_STATE_VEHICLE_MODE_1_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->speed_scale = 1.0f; p->unk2284 = 0; p->heading_locked = 0; @@ -1397,7 +1400,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { e = &D_L15_0017C228[q->attack_record]; q->saved_item[0] = 0; k = 0; - if (q->state.prev_control_mode == 6 && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { + if (q->state.prev_control_mode == HERO_MODE_ATTACK && e->unk0 == 0 && + q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 3; } { @@ -1483,7 +1487,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_HURT: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->unk1EE = scale_game_frames(0x2D); @@ -1509,7 +1513,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_WAIT_FOR_JUMP_OR_RESPAWN: { struct Hero *p = &hero; if (p->state.prev == 0x69 || - (p->state.prev2 == 0x69 && p->state.prev_control_mode != 0 && p->state.prev != 7)) { + (p->state.prev2 == 0x69 && p->state.prev_control_mode != HERO_MODE_IDLE && + p->state.prev != 7)) { p->sink_jump_count = p->sink_jump_count + 1; } else { struct Hero *q = &hero; @@ -1517,7 +1522,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *r = &hero; - r->state.control_mode = 0x19; + r->state.control_mode = HERO_MODE_RESPAWN_WAIT; r->unk2284 = 0; allocate_hero_voice_for_entry(9, 0); r->rand_timer.range = 0x68; @@ -1530,9 +1535,9 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_HEIGHT_OR_TIMEOUT_RESPAWN_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0x19; + p->state.control_mode = HERO_MODE_RESPAWN_WAIT; p->unk2284 = 0; - if (current_level_index == 0xF) + if (current_level_index == LEVEL_QUARTU) spawn_hero_radial_particle_burst(); p->collision_off_frames = 0x2710; allocate_hero_voice_for_entry(9, 0); @@ -1543,7 +1548,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_2_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (entry_animation_mode) set_hero_animation(0, 0, (float)scale_game_frames(0xF)); @@ -1551,7 +1556,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_2_REPEATABLE_SQUARE_ACTION: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unk2284 = 0; if (p->state.prev == 0x60 || (p->state.prev2 == 0x60 && scale_game_frames(0xA) > p->state.prev_timer)) { @@ -1572,7 +1577,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_2_COOLDOWN_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unk2284 = 0; if (entry_animation_mode) set_hero_animation(0xC, 0, (float)scale_game_frames(8)); @@ -1580,7 +1585,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_WAIT_FOR_CIRCLE_RELEASE_AND_ANIMATION: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unk2284 = 0; if (entry_animation_mode) set_hero_animation(8, 0, (float)scale_game_frames(8)); @@ -1588,7 +1593,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_2_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1604,7 +1609,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_2_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->unk3B8 = 0; @@ -1614,7 +1619,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_2_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -1623,7 +1628,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_2_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1638,7 +1643,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (entry_animation_mode) set_hero_animation(0, 0, (float)scale_game_frames(0xE)); @@ -1646,7 +1651,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_DELAYED_CIRCLE_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (entry_animation_mode) { set_hero_animation(4, 0, (float)scale_game_frames(7)); @@ -1656,7 +1661,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -1665,7 +1670,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1676,7 +1681,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; { char *v = (char *)&p->motion.resolved_velocity; @@ -1694,7 +1699,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (entry_animation_mode) @@ -1703,7 +1708,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_VEHICLE_MODE_3_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1719,7 +1724,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_GRIND_COLLISION_RECOVERY: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 0; if (p->rail_off_frames == 0) hero_change_health(1); @@ -1746,7 +1751,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { case HERO_STATE_LOOK_RELEASE_WAIT: { struct Hero *p = &hero; p->unk2284 = 0x51; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; if (return_hero_animation_id_unchanged(p->moby->prev_seq) != get_hero_help_value(1)) { set_hero_animation(get_hero_help_value(1), 0, (float)scale_game_frames(5)); } @@ -1770,7 +1775,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } case HERO_STATE_IDLE_ANIMATION_LONG_BLEND_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; set_hero_animation(get_hero_help_value(0), 0, (float)scale_game_frames(0xA)); break; @@ -1836,7 +1841,8 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode != 0xF && t->items[1].item_id == 0x1D && t->saved_item[1] != 0) { + if (t->state.control_mode != HERO_MODE_GRIND && t->items[1].item_id == 0x1D && + t->saved_item[1] != 0) { t->restore_item[1] = 1; } } @@ -1848,7 +1854,7 @@ int hero_set_state(int requested_state, int entry_animation_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode == 0x14) { + if (t->state.control_mode == HERO_MODE_DYING) { cancel_hero_item_animation(); t->item_use_locked = 1; } diff --git a/src/overlays/l15/hero/update_hero_motion_for_current_state.c b/src/overlays/l15/hero/update_hero_motion_for_current_state.c index 62cad161f0..edaba9fac9 100644 --- a/src/overlays/l15/hero/update_hero_motion_for_current_state.c +++ b/src/overlays/l15/hero/update_hero_motion_for_current_state.c @@ -204,10 +204,10 @@ s32 process_hero_incoming_hit(s32 apply_hit_reaction) { f32 horizontal_knockback_scale, vertical_knockback_scale, knockback_scale_factor; V_210ce8 knockback_vector; - if (hero.state.control_mode == 0x14) { + if (hero.state.control_mode == HERO_MODE_DYING) { return 0; } - if (hero.state.control_mode == 7) { + if (hero.state.control_mode == HERO_MODE_HURT) { return 0; } if (hero.state.current == 0x32) { @@ -277,20 +277,20 @@ s32 process_hero_incoming_hit(s32 apply_hit_reaction) { hero.motion.resolved_velocity_z.f[2] = frame_time * 7.0f; return 1; } - if (hero.state.control_mode == 0x12) { + if (hero.state.control_mode == HERO_MODE_WATER_SURFACE) { mob = ((u8 *)hero.damage_source_moby); if (mob != 0 && *(s16 *)(mob + 0xA6) == 0x28F) { id = 0x82; goto call_ret; } hero_set_state(0x75, 1); - } else if (hero.state.control_mode == 0x11) { + } else if (hero.state.control_mode == HERO_MODE_SWIM) { mob = ((u8 *)hero.damage_source_moby); if (mob != 0 && *(s16 *)(mob + 0xA6) == 0x28F) { id = 0x82; goto call_ret; } - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || current_level_index == LEVEL_VELDIN_ORBIT) { mob = ((u8 *)hero.damage_source_moby); if (mob != 0 && (*(s16 *)(mob + 0xA6) == 0x28F || *(s16 *)(mob + 0xA6) == 0x7B || *(s16 *)(mob + 0xA6) == 0x29D)) { @@ -298,7 +298,7 @@ s32 process_hero_incoming_hit(s32 apply_hit_reaction) { } } hero_set_state(0x76, 1); - } else if (hero.state.control_mode == 3) { + } else if (hero.state.control_mode == HERO_MODE_LEDGE) { mob = ((u8 *)hero.damage_source_moby); if (mob != 0) { id = 0x82; @@ -1993,12 +1993,12 @@ void update_hero_motion_for_current_state(void) { f32 f; f32 old; f32 d; - if (current_level_index == 0xF) { + if (current_level_index == LEVEL_QUARTU) { release_voice_slot_cf(2, (struct MobyView *)hero.moby, 0x1D); } else { release_voice_slot_cf(2, (struct MobyView *)hero.moby, 6); } - if (current_level_index != 0xF) { + if (current_level_index != LEVEL_QUARTU) { emit_hero_randomized_motion_effects(4, 2); spatial_or_hit_descriptor_work.f[0] = hero.motion.pos.f[0] + random_float_between(-0.25f, 0.25f); diff --git a/src/overlays/l15/hero/update_hero_state_machine.c b/src/overlays/l15/hero/update_hero_state_machine.c index 5d06e1d0b9..3916d38904 100644 --- a/src/overlays/l15/hero/update_hero_state_machine.c +++ b/src/overlays/l15/hero/update_hero_state_machine.c @@ -165,7 +165,7 @@ void update_hero_state_machine(void) { prevState = hero.state.step; prevAnim = MOBY(moby)->prev_seq; if (process_hero_incoming_hit(1) == 0) { - if (hero.health.hp <= 0 && hero.state.control_mode != 0x14 && + if (hero.health.hp <= 0 && hero.state.control_mode != HERO_MODE_DYING && (hero.state.current == HERO_STATE_IDLE || hero.state.current == HERO_STATE_RUN)) { hero_set_state(HERO_STATE_DYING, 1); } else if (process_hero_item_action_input() == 0 && try_enter_hero_water_state() == 0 && @@ -417,7 +417,7 @@ void update_hero_state_machine(void) { } } if (ok && 0.22f < hero.stick_magnitude) { - if (current_level_index == 0xC) { + if (current_level_index == LEVEL_HOVEN) { int slot = hero.ground_sound_class; request_hero_voice_if_enabled(slot, 0, 0); request_hero_voice_if_enabled(slot, 1, 0); @@ -601,7 +601,8 @@ void update_hero_state_machine(void) { break; case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: if (hero.health.hp <= 0) { - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || + current_level_index == LEVEL_VELDIN_ORBIT) { hero_set_state(0x82, 1); break; } @@ -776,7 +777,8 @@ void update_hero_state_machine(void) { break; } if (!(hero.air_frames.s < scale_game_frames(5)) && - !(hero.state.prev_control_mode == 0x12 && hero.wading != 0) && + !(hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE && + hero.wading != 0) && hero.ground_distance > 1.35f) { if (check_hero_forward_collision_height() == 0) { hero_set_state(HERO_STATE_FALL, 1); @@ -836,7 +838,8 @@ void update_hero_state_machine(void) { } } if (hero.state_timer > scale_game_frames(0xF) || - (hero.state.prev_control_mode != 0 && hero.state.prev_control_mode != 1)) { + (hero.state.prev_control_mode != HERO_MODE_IDLE && + hero.state.prev_control_mode != HERO_MODE_RUN)) { if ((controller_state.pressed & 0x10000) && hero.unk20AA == 0) { hero.unk3BE = 1; } @@ -1383,9 +1386,9 @@ void update_hero_state_machine(void) { } break; case HERO_STATE_FATAL_FALL: - if ((current_level_index == 3 && 5.0f > hero.motion.pos.f[2]) || - (current_level_index == 6 && 50.0f > hero.motion.pos.f[2]) || - (current_level_index == 0x10 && + if ((current_level_index == LEVEL_KERWAN && 5.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_NEBULA_G34 && 50.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_KALEBO3 && (77.0f > hero.motion.pos.f[2] || (hero.state_timer > 0x14 && hero.wall_hit != 0 && hero.motion.displacement.f[2] >= 0.0f))) || diff --git a/src/overlays/l15/mobys/cutscene_mobys.c b/src/overlays/l15/mobys/cutscene_mobys.c index 79e6933096..4539255ee3 100644 --- a/src/overlays/l15/mobys/cutscene_mobys.c +++ b/src/overlays/l15/mobys/cutscene_mobys.c @@ -23,7 +23,7 @@ void update_level15_cutscene_mobys(void) __asm__("FUN_L15 void update_level15_cutscene_mobys(void) { int i; - if (current_level_index == 15 && (unsigned)(cutscene_state.scene - 3) < 2) { + if (current_level_index == LEVEL_QUARTU && (unsigned)(cutscene_state.scene - 3) < 2) { for (i = 0; i < cutscene_state.moby_count; i++) { FUN_L00_00257024(cutscene_state.mobys[i]); } diff --git a/src/overlays/l16/hero/apply_hero_ground_material_effects.c b/src/overlays/l16/hero/apply_hero_ground_material_effects.c index 5b6926ddcf..3c63a0f132 100644 --- a/src/overlays/l16/hero/apply_hero_ground_material_effects.c +++ b/src/overlays/l16/hero/apply_hero_ground_material_effects.c @@ -230,7 +230,7 @@ void update_hero_ground_contact(void) { if (hero.gravity_mode) k = 1; ground_probe_start_offset = hero.capsule_radius * 2.2f; - if (hero.state.control_mode == 2) { + if (hero.state.control_mode == HERO_MODE_FALL) { ground_probe_start_offset = hero.capsule_radius * 2.9f; } hero_get_collision_ray_endpoints( @@ -256,7 +256,7 @@ void update_hero_ground_contact(void) { goto d1; } collision_sound_class = coll_sound_class(); - if (current_level_index == 1 || current_level_index == 0x12) { + if (current_level_index == LEVEL_NOVALIS || current_level_index == LEVEL_VELDIN2) { collision_sound_class = 3; } hero.ground_sound_class = collision_sound_class; @@ -341,9 +341,9 @@ void update_hero_ground_contact(void) { hero.unk2C8.i[1] = 0; hero.unk2C0.i[0] = 0; hero.unk2C0.i[1] = 0; - if (hero.state.control_mode == 0xF || hero.state.control_mode == 0x15 || - hero.state.control_mode == 6 || hero.state.control_mode == 4 || - hero.state.control_mode == 5 || hero.state.control_mode == 3) { + if (hero.state.control_mode == HERO_MODE_GRIND || hero.state.control_mode == 0x15 || + hero.state.control_mode == HERO_MODE_ATTACK || hero.state.control_mode == HERO_MODE_JUMP || + hero.state.control_mode == HERO_MODE_LAND || hero.state.control_mode == HERO_MODE_LEDGE) { return; } if (!(hero.ground_distance < 0.25f)) { @@ -424,7 +424,7 @@ s32 resolve_hero_position_collisions(s32 mode) { resolve_hero_pending_path_clearance(); hero.path_constrain_pending = 0; } - if (hero.state.control_mode != 0x11) { + if (hero.state.control_mode != HERO_MODE_SWIM) { if (hero.state.control_mode == 0x16) { transform_hero_local_offset_to_world(&collision_position_offset, 0.0f, 0.0f, 0.7f); fast_vec_sub( @@ -450,13 +450,13 @@ s32 resolve_hero_position_collisions(s32 mode) { if (hero.gravity_mode != HERO_GRAVITY_WORLD_DOWN) { if (!coll1_2133a8(&hero.motion.pos.q, mask, ((s32)hero.moby), frame_scale * 0.4f)) break; - } else if (hero.state.control_mode == 0x11) { + } else if (hero.state.control_mode == HERO_MODE_SWIM) { if (!coll1_2133a8(&hero.motion.pos.q, mask, ((s32)hero.moby), 0.6f)) break; } else if (hero.state.control_mode == 0x16) { if (!coll1_2133a8(&hero.motion.pos.q, mask, ((s32)hero.moby), frame_scale * 0.5f)) break; - } else if (hero.state.control_mode == 0xF) { + } else if (hero.state.control_mode == HERO_MODE_GRIND) { if (!coll1_2133a8(&hero.motion.pos.q, mask, ((s32)hero.moby), frame_scale * 0.45f)) break; } else { diff --git a/src/overlays/l16/hero/hero_set_state.c b/src/overlays/l16/hero/hero_set_state.c index 5156c7d308..1a2f98af5f 100644 --- a/src/overlays/l16/hero/hero_set_state.c +++ b/src/overlays/l16/hero/hero_set_state.c @@ -89,7 +89,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { float vec[4]; { struct Hero *p = &hero; - if (p->state.control_mode == 0x14 && + if (p->state.control_mode == HERO_MODE_DYING && (requested_state != HERO_STATE_IDLE_ANIMATION_WITH_DYING_OVERRIDE || animation_update_mode != HERO_ANIMATION_ENTRY_OVERRIDE_GUARDS)) return 0; @@ -99,7 +99,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { return 0; { struct Hero *p = &hero; - if (p->health.hp == 0 && (p->state.control_mode == 2 || p->state.control_mode == 7) && + if (p->health.hp == 0 && + (p->state.control_mode == HERO_MODE_FALL || p->state.control_mode == HERO_MODE_HURT) && requested_state != HERO_STATE_FALL && requested_state != HERO_STATE_DYING && requested_state != HERO_STATE_VEHICLE_MODE_1_DYING && requested_state != HERO_STATE_VEHICLE_MODE_3_DYING && @@ -150,7 +151,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { switch (requested_state) { case HERO_STATE_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; p->unk1010 = random_int_between(scale_game_frames(0x32), scale_game_frames(0x64)); clear_hero_idle_rotation_targets(); @@ -179,7 +180,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_AT_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; clear_u64_value(&p->motion.momentum); p->rand_timer.range = 0x68; @@ -206,7 +207,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (animation_update_mode) @@ -215,7 +216,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DYING_SPEED_LIMITED: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -226,7 +227,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_SINK: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->unk694 = p->motion.displacement.f[2] * 0.2f; @@ -242,11 +243,11 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_SWIM: { struct Hero *p = &hero; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; *(int *)&p->drown_sink_speed = 0; - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } else { @@ -266,11 +267,11 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_SWIM_WITH_CROUCH_INPUT: { struct Hero *p = &hero; int n; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; p->unk8F4 = scale_game_frames(0x3C); - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } @@ -287,7 +288,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { struct Hero *p = &hero; int n; int t; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -302,11 +303,11 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_WATER_SURFACE_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; p->splash_effect_timer = 0; - if (p->state.prev_control_mode == 0x11) { + if (p->state.prev_control_mode == HERO_MODE_SWIM) { emit_hero_surface_effect_burst(3, 0xA, 0); if (D_L16_001612D0 != 0) { pool_splash(D_L16_001612D0, @@ -337,7 +338,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { { struct Hero *q = &hero; q->unk698 = 0; - if (q->state.prev_control_mode == 0x11) { + if (q->state.prev_control_mode == HERO_MODE_SWIM) { float d = (float)q->underwater_air; if (d < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); @@ -346,7 +347,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } { struct Hero *r = &hero; - if (r->state.prev_control_mode == 0x11) { + if (r->state.prev_control_mode == HERO_MODE_SWIM) { float e = (float)r->underwater_air; if (e < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); @@ -378,7 +379,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->item_select_blocked = 1; @@ -411,7 +412,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_WATER_SURFACE_MOVE: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; *(int *)&p->drown_sink_speed = 0; @@ -423,7 +424,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DROWN: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -463,7 +464,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DYING_ZERO_HEALTH: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -513,7 +514,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { struct Hero *q = &hero; if (q->state.prev_control_mode != 0x16) { char *m; - if (current_level_index == 5) { + if (current_level_index == LEVEL_RILGAR) { q->motion.pos.f[0] = 247.0f; q->motion.pos.f[1] = 287.0f; q->motion.pos.f[2] = 76.0f; @@ -644,7 +645,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_LOOK: { struct Hero *p = &hero; int t; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 4; *(int *)&D_L16_0015F688 = scale_game_frames(0x3C); if (p->unk20AA == 0) { @@ -657,7 +658,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ITEM_BUTTON_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(0xA)); @@ -666,7 +667,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_WAIT_FOR_ITEM_RELEASE_THEN_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(5)); @@ -675,7 +676,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ITEM_BUTTON_HOLD_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.displacement); p->state.step = 0; @@ -688,9 +689,10 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_DIRECTION_LIMITED_GROUND_MOVE: case HERO_STATE_SHALLOW_WATER_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; - if (p->state.prev_control_mode != 4 && p->state.prev2_control_mode != 4) { + if (p->state.prev_control_mode != HERO_MODE_JUMP && + p->state.prev2_control_mode != HERO_MODE_JUMP) { p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); } { @@ -701,7 +703,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { stick_target(1.0f, 0); if (1.5707964f < fast_difference_between_rotations(q->motion.rot.f[2], q->motion.move_yaw)) { - if (q->state.prev_control_mode == 7 || q->state.prev == 3 || q->state.prev2 == 3) { + if (q->state.prev_control_mode == HERO_MODE_HURT || q->state.prev == 3 || + q->state.prev2 == 3) { struct Hero *r = &hero; r->ground_speed = 0.0f; } @@ -737,7 +740,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { n = scale_game_frames(0x12); { struct Hero *u = &hero; - if (u->state.prev2_control_mode == 4 && + if (u->state.prev2_control_mode == HERO_MODE_JUMP && scale_game_frames(5) < u->rail_land_frames) n = scale_game_frames(0xD); } @@ -751,7 +754,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ANIMATION_FRAME_EXIT_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; if (animation_update_mode) { if (p->state.prev == 4) { @@ -764,7 +767,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_APPROACH_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->item_use_locked = 1; @@ -795,7 +798,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_STOP: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (p->on_slip_ground != 0 && p->frames_off_ground.s == 0) { @@ -824,7 +827,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_BRAKE_AT_TARGET_POSITION: { struct Hero *p = &hero; char *v = (char *)&p->motion.resolved_velocity; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = gravity_length_xy((float *)v); qcopy(&p->motion.momentum, v); @@ -839,7 +842,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_CROUCH: { struct Hero *p = &hero; - p->state.control_mode = 0xC; + p->state.control_mode = HERO_MODE_CROUCH; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); if (frame_time * 7.0f < p->ground_speed) @@ -868,7 +871,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_GRAPPLE_TARGET_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -890,7 +893,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_APPROACH_TARGET_MOBY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; *(int *)&p->grapple_pull_speed = 0; p->grapple_pull_ending = 0; @@ -901,7 +904,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_CONSTRAIN_TO_TARGET_RADIUS: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; p->item_use_locked = 1; *(int *)&p->grapple_pull_speed = 0; @@ -914,7 +917,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_GRAPPLE_SWING_ENTRY: { struct Hero *p = &hero; char *d; - p->state.control_mode = 0xE; + p->state.control_mode = HERO_MODE_GRAPPLE_SWING; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -958,9 +961,9 @@ int hero_set_state(int requested_state, int animation_update_mode) { q->swing_target_moby->pos.y - q->motion.pos.f[1]); q->unk9A4 = fast_vec_dist(&q->motion.pos, &q->swing_target_moby->pos); q->swing_gravity = frame_time_sq * 27.0f; - if (q->state.prev_control_mode == 4) { + if (q->state.prev_control_mode == HERO_MODE_JUMP) { q->swing_gravity = q->jump_gravity; - } else if (q->state.prev_control_mode == 2) { + } else if (q->state.prev_control_mode == HERO_MODE_FALL) { q->swing_gravity = q->fall_state_gravity; } if (animation_update_mode) { @@ -975,7 +978,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ITEM_RELEASE_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 7; clear_u64_value(&p->motion.rot_spring_vel); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1000,14 +1003,14 @@ int hero_set_state(int requested_state, int animation_update_mode) { float pos[4]; int seg; float t; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 3; p->rand_timer.range = 0x68; p->rail_off_frames = 0; p->grind_direction = 1; p->grind_yaw_offset = -1.5707964f; p->grind_anim_variant = 0; - if (p->state.prev_control_mode != 0xF) { + if (p->state.prev_control_mode != HERO_MODE_GRIND) { p->grind_pose = -1; p->unk5AC.i = 0; p->grind_base_speed = 0.0f; @@ -1022,7 +1025,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { fast_vec_sub(vec, pos, &p->motion.pos); if (0.001f < fast_vec_length(vec)) { fast_vec_normalize(vec, vec, 1.0f); - if (p->state.prev_control_mode != 0xF) { + if (p->state.prev_control_mode != HERO_MODE_GRIND) { p->grind_base_speed = fast_vec_dot(&p->motion.displacement, vec); } } @@ -1048,11 +1051,11 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 24.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -1068,7 +1071,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -1078,7 +1081,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_LEDGE_SHIMMY_POSITIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (animation_update_mode) @@ -1087,7 +1090,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_LEDGE_SHIMMY_NEGATIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (animation_update_mode) @@ -1096,7 +1099,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (animation_update_mode) @@ -1106,7 +1109,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_FALL: case HERO_STATE_FATAL_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1141,7 +1144,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_DELAYED_JUMP_OR_R1_REPEAT_EXIT_WAIT: { struct Hero *p = &hero; int animation_timing_value = -2; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk22CA = 1; p->rand_timer.range = 0x68; p->unk2284 = 0; @@ -1157,7 +1160,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_LAND: { struct Hero *p = &hero; int animation_timing_arg = -2; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->rand_timer.range = 0x68; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { @@ -1195,7 +1198,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { p->state_timer = p->state.prev_timer; return 0; } - p->state.control_mode = 4; + p->state.control_mode = HERO_MODE_JUMP; if (requested_state >= HERO_STATE_GRIND_JUMP && requested_state <= HERO_STATE_GRIND_RAIL_TRANSFER) { p->unk2284 = 3; @@ -1294,7 +1297,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { u->unk48C = 2.45f; u->jump_height_start = 2.4f; u->unk498 = scale_game_frames(0x11); - u->state.control_mode = 0xF; + u->state.control_mode = HERO_MODE_GRIND; u->rail_gap_jump = 0; u->jump_gravity = frame_time_sq * 27.0f; if (u->selector_5 != 0) { @@ -1324,7 +1327,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { u->unk48C = 2.55f; u->jump_height_start = 2.5f; u->unk498 = scale_game_frames(0xA); - u->state.control_mode = 0xF; + u->state.control_mode = HERO_MODE_GRIND; u->rail_gap_jump = 0; u->jump_gravity = frame_time_sq * 24.0f; } else if (u->state.current == 9) { @@ -1542,7 +1545,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } else if (s == 0xA) { set_hero_animation(0x12, 0, (float)scale_game_frames(5)); } else if (s == 0x10) { - if (q->state.prev_control_mode == 4 || + if (q->state.prev_control_mode == HERO_MODE_JUMP || (q->state.prev == 4 && scale_game_frames(7) > q->state_timer)) { set_hero_animation(0x26, 0, (float)scale_game_frames(8)); q->takeoff_frame += scale_game_frames(3); @@ -1574,7 +1577,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } { struct Hero *w = &hero; - if (w->state.prev_control_mode == 4) { + if (w->state.prev_control_mode == HERO_MODE_JUMP) { set_hero_animation(id, 1, (float)scale_game_frames(4)); w->takeoff_frame = scale_game_frames(1); } else { @@ -1593,7 +1596,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_ANIMATION_RECOVERY_WITH_JUMP_CANCEL: case HERO_STATE_VEHICLE_MODE_1_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->speed_scale = 1.0f; p->unk2284 = 0; p->heading_locked = 0; @@ -1693,7 +1696,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { e = &D_L16_0017C088[q->attack_record]; q->saved_item[0] = 0; k = 0; - if (q->state.prev_control_mode == 6 && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { + if (q->state.prev_control_mode == HERO_MODE_ATTACK && e->unk0 == 0 && + q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 3; } { @@ -1748,7 +1752,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ATTACK_RECORD_FRAME_EXIT_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unkA64 = 0; if (p->state.prev == 0x70) { int v = 5; @@ -1775,7 +1779,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_GRIND_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unkA64 = 0; if (p->state.prev == 0x2B) { p->attack_record = p->attack_record == 0; @@ -1826,7 +1830,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_HURT: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->unk1EE = scale_game_frames(0x2D); @@ -1851,7 +1855,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (animation_update_mode) set_hero_animation(0, 0, (float)scale_game_frames(0xE)); @@ -1859,7 +1863,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DELAYED_CIRCLE_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (animation_update_mode) { set_hero_animation(4, 0, (float)scale_game_frames(7)); @@ -1869,7 +1873,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (animation_update_mode) @@ -1878,7 +1882,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1889,7 +1893,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; { char *v = (char *)&p->motion.resolved_velocity; @@ -1907,7 +1911,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (animation_update_mode) @@ -1916,7 +1920,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1932,7 +1936,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_GRIND_COLLISION_RECOVERY: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 0; if (p->rail_off_frames == 0) hero_change_health(1); @@ -1959,7 +1963,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_LOOK_RELEASE_WAIT: { struct Hero *p = &hero; p->unk2284 = 0x51; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; if (return_hero_animation_id_unchanged(p->moby->prev_seq) != get_hero_idle_animation_index(1)) { set_hero_animation(get_hero_idle_animation_index(1), 0, (float)scale_game_frames(5)); @@ -1984,7 +1988,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_IDLE_ANIMATION_LONG_BLEND_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; set_hero_animation(get_hero_idle_animation_index(0), 0, (float)scale_game_frames(0xA)); break; @@ -2050,7 +2054,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode != 0xF && t->items[1].item_id == 0x1D && t->saved_item[1] != 0) { + if (t->state.control_mode != HERO_MODE_GRIND && t->items[1].item_id == 0x1D && + t->saved_item[1] != 0) { t->restore_item[1] = 1; } } @@ -2062,7 +2067,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode == 0x14) { + if (t->state.control_mode == HERO_MODE_DYING) { cancel_hero_item_animation(); t->item_use_locked = 1; } diff --git a/src/overlays/l16/hero/update_hero_motion_for_current_state.c b/src/overlays/l16/hero/update_hero_motion_for_current_state.c index 0d94dde08b..7a788539eb 100644 --- a/src/overlays/l16/hero/update_hero_motion_for_current_state.c +++ b/src/overlays/l16/hero/update_hero_motion_for_current_state.c @@ -2184,12 +2184,12 @@ void update_hero_motion_for_current_state(void) { f32 f; f32 old; f32 d; - if (current_level_index == 0xF) { + if (current_level_index == LEVEL_QUARTU) { release_voice_slot_cf(2, (struct MobyView *)hero.moby, 0x1D); } else { release_voice_slot_cf(2, (struct MobyView *)hero.moby, 6); } - if (current_level_index != 0xF) { + if (current_level_index != LEVEL_QUARTU) { emit_hero_randomized_motion_effects(4, 2); primary_vector_scratch.f[0] = hero.motion.pos.f[0] + random_float_between(-0.25f, 0.25f); diff --git a/src/overlays/l16/hero/update_hero_state_transitions.c b/src/overlays/l16/hero/update_hero_state_transitions.c index 79b1a80b33..74d8adb321 100644 --- a/src/overlays/l16/hero/update_hero_state_transitions.c +++ b/src/overlays/l16/hero/update_hero_state_transitions.c @@ -187,7 +187,7 @@ void update_hero_state_transitions(void) { prevState = hero.state.step; prevAnim = MOBY(moby)->prev_seq; if (handle_hero_hit(1) == 0) { - if (hero.health.hp <= 0 && hero.state.control_mode != 0x14 && + if (hero.health.hp <= 0 && hero.state.control_mode != HERO_MODE_DYING && (hero.state.current == HERO_STATE_IDLE || hero.state.current == HERO_STATE_RUN)) { hero_set_state(HERO_STATE_DYING, 1); } else if (process_hero_primary_item_input() == 0 && @@ -446,7 +446,7 @@ void update_hero_state_transitions(void) { } } if (ok && 0.22f < hero.stick_magnitude) { - if (current_level_index == 0xC) { + if (current_level_index == LEVEL_HOVEN) { int slot = hero.ground_sound_class; request_hero_voice_if_enabled(slot, 0, 0); request_hero_voice_if_enabled(slot, 1, 0); @@ -637,7 +637,8 @@ void update_hero_state_transitions(void) { break; case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: if (hero.health.hp <= 0) { - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || + current_level_index == LEVEL_VELDIN_ORBIT) { hero_set_state(0x82, 1); break; } @@ -815,7 +816,8 @@ void update_hero_state_transitions(void) { break; } if (!(hero.air_frames.s < scale_game_frames(5)) && - !(hero.state.prev_control_mode == 0x12 && hero.wading != 0) && + !(hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE && + hero.wading != 0) && hero.ground_distance > 1.35f) { if (check_hero_forward_collision_height() == 0) { hero_set_state(HERO_STATE_FALL, 1); @@ -882,7 +884,8 @@ void update_hero_state_transitions(void) { break; } if (hero.state_timer > scale_game_frames(0xF) || - (hero.state.prev_control_mode != 0 && hero.state.prev_control_mode != 1)) { + (hero.state.prev_control_mode != HERO_MODE_IDLE && + hero.state.prev_control_mode != HERO_MODE_RUN)) { if ((controller_state.pressed & 0x10000) && hero.unk20AA == 0) { hero.unk3BE = 1; } @@ -1249,7 +1252,7 @@ void update_hero_state_transitions(void) { } else { int ice = 0; - if (current_level_index == 0x10 && hero.wall_hit != 0 && + if (current_level_index == LEVEL_KALEBO3 && hero.wall_hit != 0 && ((unsigned char *)hero.coll_hit_moby) != 0 && *(short *)(((unsigned char *)hero.coll_hit_moby) + 0xA6) == 0x101) { ice = 1; @@ -1260,7 +1263,7 @@ void update_hero_state_transitions(void) { ice || hero.unk5BE != 0) { int ok = 1; - if (current_level_index != 0x10) { + if (current_level_index != LEVEL_KALEBO3) { qcopy(v0, hero.rail_point.f); v0[2] += 2.0f; v1[0] = fast_cos(hero.rail_dir_yaw) * 5.0f; @@ -1310,7 +1313,7 @@ void update_hero_state_transitions(void) { if (hero.state.current == HERO_STATE_GRIND) { int can = 1; - if (current_level_index == 8) { + if (current_level_index == LEVEL_BATALIA) { *(OvlQuad *)v0 = 0; v0[0] = 342.0f; v0[1] = 111.1f; @@ -1811,9 +1814,9 @@ void update_hero_state_transitions(void) { } break; case HERO_STATE_FATAL_FALL: - if ((current_level_index == 3 && 5.0f > hero.motion.pos.f[2]) || - (current_level_index == 6 && 50.0f > hero.motion.pos.f[2]) || - (current_level_index == 0x10 && + if ((current_level_index == LEVEL_KERWAN && 5.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_NEBULA_G34 && 50.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_KALEBO3 && (77.0f > hero.motion.pos.f[2] || (hero.state_timer > 0x14 && hero.wall_hit != 0 && hero.motion.displacement.f[2] >= 0.0f))) || @@ -2321,8 +2324,8 @@ void update_hero_state_transitions(void) { hero_set_state(HERO_STATE_FALL, 1); break; } - if (current_level_index == 0x10 && hero.motion.velocity.f[2] < 0.0f && - hero.health.hp == 0 && hero.state.prev_control_mode == 0xF) { + if (current_level_index == LEVEL_KALEBO3 && hero.motion.velocity.f[2] < 0.0f && + hero.health.hp == 0 && hero.state.prev_control_mode == HERO_MODE_GRIND) { hero_set_state(0x77, 1); break; } @@ -2508,7 +2511,7 @@ void update_hero_state_transitions(void) { update_hero_hoverboard_trick_score(); break; case HERO_STATE_HOVERBOARD_RESPAWN_HEIGHT_OR_ANIMATION_WAIT: - if (current_level_index == 5 && 61.4f > hero.motion.pos.f[2]) { + if (current_level_index == LEVEL_RILGAR && 61.4f > hero.motion.pos.f[2]) { hero.board_floor_z = 61.4f; hero_set_state(0x6E, 1); hero.board_respawn_delay = scale_game_frames(0x46) - hero.state_timer; @@ -2517,7 +2520,7 @@ void update_hero_state_transitions(void) { } return; } - if (current_level_index == 0x10 && 76.0f > hero.motion.pos.f[2]) { + if (current_level_index == LEVEL_KALEBO3 && 76.0f > hero.motion.pos.f[2]) { hero.board_floor_z = 76.0f; hero_set_state(0x6E, 1); hero.board_respawn_delay = scale_game_frames(0x46) - hero.state_timer; diff --git a/src/overlays/l16/mobys/help_desk_lady.c b/src/overlays/l16/mobys/help_desk_lady.c index 92d69eddfa..a140c7017a 100644 --- a/src/overlays/l16/mobys/help_desk_lady.c +++ b/src/overlays/l16/mobys/help_desk_lady.c @@ -163,7 +163,7 @@ void help_desk_lady_update(L16WatchMoby *moby) { is_point_inside_clip_volume((char *)&D_0013E533 + 0xE9D, watch_data->entry_region)) flags->entered = 1; if (!((L16WatchFlags *)((char *)&D_0013D355_watch + 0x13B))->mission && - hero.state.control_mode == 15) + hero.state.control_mode == HERO_MODE_GRIND) ((L16WatchFlags *)((char *)&D_0013D355_watch + 0x13B))->mission = 1; rate = 0.02f; head_rate = 0.3f; diff --git a/src/overlays/l16/mobys/path_following_rocket.c b/src/overlays/l16/mobys/path_following_rocket.c index d10a82bb96..1ae0b612d5 100644 --- a/src/overlays/l16/mobys/path_following_rocket.c +++ b/src/overlays/l16/mobys/path_following_rocket.c @@ -66,7 +66,7 @@ void path_following_rocket_update(struct Moby *moby) { break; case ROCKET_STATE_WAIT_FOR_TRIGGER: { struct Hero *player = &hero; - if (player->state.control_mode != 15) + if (player->state.control_mode != HERO_MODE_GRIND) break; if (is_point_inside_clip_volume(&player->motion.body_center, *(int *)rocket_path_data)) { moby->state = ROCKET_STATE_FOLLOW_PATH; diff --git a/src/overlays/l16/render_level16_sky_shells.c b/src/overlays/l16/render_level16_sky_shells.c index 3d64372879..9f00316086 100644 --- a/src/overlays/l16/render_level16_sky_shells.c +++ b/src/overlays/l16/render_level16_sky_shells.c @@ -11,7 +11,7 @@ void render_level16_sky_shells(void) __asm__("FUN_L16_00239c30"); void render_level16_sky_shells(void) { setup_sky_gif_paging(); - if (current_level_index == 0x10) { + if (current_level_index == LEVEL_KALEBO3) { draw_sky_shells_with_slow_medium_and_fast_rotation(); } else { update_sky_shells_static(); diff --git a/src/overlays/l17/hero/hero_set_state.c b/src/overlays/l17/hero/hero_set_state.c index 6a454bc6c0..e769a2f37d 100644 --- a/src/overlays/l17/hero/hero_set_state.c +++ b/src/overlays/l17/hero/hero_set_state.c @@ -103,7 +103,7 @@ int hero_set_state(int requested_state, int b) { V4_21ED38 sampled_path_position; { struct Hero *p = &hero; - if (p->state.control_mode == 0x14 && + if (p->state.control_mode == HERO_MODE_DYING && (requested_state != HERO_STATE_IDLE_ANIMATION_WITH_DYING_OVERRIDE || b != 2)) return 0; } @@ -111,7 +111,8 @@ int hero_set_state(int requested_state, int b) { return 0; { struct Hero *p = &hero; - if (p->health.hp == 0 && (p->state.control_mode == 2 || p->state.control_mode == 7) && + if (p->health.hp == 0 && + (p->state.control_mode == HERO_MODE_FALL || p->state.control_mode == HERO_MODE_HURT) && requested_state != HERO_STATE_FALL && requested_state != HERO_STATE_DYING && requested_state != HERO_STATE_VEHICLE_MODE_1_DYING && requested_state != HERO_STATE_VEHICLE_MODE_3_DYING && @@ -162,7 +163,7 @@ int hero_set_state(int requested_state, int b) { switch (requested_state) { case HERO_STATE_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; p->unk1010 = random_int_between(scale_game_frames(0x32), scale_game_frames(0x64)); clear_hero_idle_rotation_targets(); @@ -197,7 +198,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_AT_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; clear_u64_value(&p->motion.momentum); p->rand_timer.range = 0x68; @@ -223,7 +224,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (b) @@ -232,7 +233,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_DYING_SPEED_LIMITED: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -243,7 +244,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_SINK: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->unk694 = p->motion.displacement.f[2] * 0.2f; @@ -259,11 +260,11 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_SWIM: { struct Hero *p = &hero; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; *(int *)&p->drown_sink_speed = 0; - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } else { @@ -283,11 +284,11 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_SWIM_WITH_CROUCH_INPUT: { struct Hero *p = &hero; int n; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; p->unk8F4 = scale_game_frames(0x3C); - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } @@ -303,7 +304,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_SWIM_IDLE: { struct Hero *p = &hero; int n; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -317,11 +318,11 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_WATER_SURFACE_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; p->splash_effect_timer = 0; - if (p->state.prev_control_mode == 0x11) { + if (p->state.prev_control_mode == HERO_MODE_SWIM) { emit_hero_surface_effect_burst(3, 0xA, 0); if (D_L17_001612D0 != 0) { pool_splash(D_L17_001612D0, @@ -349,7 +350,7 @@ int hero_set_state(int requested_state, int b) { { struct Hero *q = &hero; q->unk698 = 0; - if (q->state.prev_control_mode == 0x11) { + if (q->state.prev_control_mode == HERO_MODE_SWIM) { if ((float)q->underwater_air < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); } else if ((float)q->underwater_air < 7500.0f) { @@ -357,7 +358,7 @@ int hero_set_state(int requested_state, int b) { } { struct Hero *r = &hero; - if (r->state.prev_control_mode == 0x11) { + if (r->state.prev_control_mode == HERO_MODE_SWIM) { if ((float)r->underwater_air < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); } else if ((float)r->underwater_air < 7500.0f) { @@ -388,7 +389,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->item_select_blocked = 1; @@ -421,7 +422,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_WATER_SURFACE_MOVE: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; *(int *)&p->drown_sink_speed = 0; @@ -433,7 +434,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_DROWN: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -475,7 +476,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_DYING_ZERO_HEALTH: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -511,7 +512,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_LOOK: { struct Hero *p = &hero; int t; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 4; *(int *)&D_L17_0015F688 = scale_game_frames(0x3C); if (p->unk20AA == 0) { @@ -524,7 +525,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ITEM_BUTTON_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(select_hero_help_value(0), 0, (float)scale_game_frames(0xA)); @@ -533,7 +534,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_WAIT_FOR_ITEM_RELEASE_THEN_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(select_hero_help_value(0), 0, (float)scale_game_frames(5)); @@ -542,7 +543,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ITEM_BUTTON_HOLD_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.displacement); p->state.step = 0; @@ -556,9 +557,10 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_DIRECTION_LIMITED_GROUND_MOVE: case HERO_STATE_SHALLOW_WATER_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; - if (p->state.prev_control_mode != 4 && p->state.prev2_control_mode != 4) { + if (p->state.prev_control_mode != HERO_MODE_JUMP && + p->state.prev2_control_mode != HERO_MODE_JUMP) { p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); } { @@ -569,7 +571,8 @@ int hero_set_state(int requested_state, int b) { stick_target(0, 1.0f); if (1.5707964f < fast_difference_between_rotations(q->motion.rot.f[2], q->motion.move_yaw)) { - if (q->state.prev_control_mode == 7 || q->state.prev == 3 || q->state.prev2 == 3) { + if (q->state.prev_control_mode == HERO_MODE_HURT || q->state.prev == 3 || + q->state.prev2 == 3) { struct Hero *r = &hero; r->ground_speed = 0.0f; } @@ -613,7 +616,7 @@ int hero_set_state(int requested_state, int b) { n = scale_game_frames(0x12); { struct Hero *u = &hero; - if (u->state.prev2_control_mode == 4 && + if (u->state.prev2_control_mode == HERO_MODE_JUMP && scale_game_frames(5) < u->rail_land_frames) n = scale_game_frames(0xD); } @@ -627,7 +630,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ANIMATION_FRAME_EXIT_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; if (b) { if (p->state.prev == 4) { @@ -640,7 +643,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_APPROACH_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->item_use_locked = 1; @@ -671,7 +674,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_STOP: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (p->on_ice_ground != 0) { @@ -703,7 +706,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_BRAKE_AT_TARGET_POSITION: { struct Hero *p = &hero; char *v = &p->motion.resolved_velocity; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = gravity_length_xy((float *)v); qcopy(&p->motion.momentum, v); @@ -718,7 +721,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_CROUCH: { struct Hero *p = &hero; - p->state.control_mode = 0xC; + p->state.control_mode = HERO_MODE_CROUCH; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); if (frame_time * 7.0f < p->ground_speed) @@ -747,7 +750,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_GRAPPLE_TARGET_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -769,7 +772,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_APPROACH_TARGET_MOBY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; *(int *)&p->grapple_pull_speed = 0; p->grapple_pull_ending = 0; @@ -780,7 +783,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_CONSTRAIN_TO_TARGET_RADIUS: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; p->item_use_locked = 1; *(int *)&p->grapple_pull_speed = 0; @@ -793,7 +796,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_GRAPPLE_SWING_ENTRY: { struct Hero *p = &hero; char *d; - p->state.control_mode = 0xE; + p->state.control_mode = HERO_MODE_GRAPPLE_SWING; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -837,9 +840,9 @@ int hero_set_state(int requested_state, int b) { q->swing_target_moby->pos.y - q->motion.pos.f[1]); q->unk9A4 = fast_vec_dist(&q->motion.pos, &q->swing_target_moby->pos); q->swing_gravity = frame_time_sq * 27.0f; - if (q->state.prev_control_mode == 4) { + if (q->state.prev_control_mode == HERO_MODE_JUMP) { q->swing_gravity = q->jump_gravity; - } else if (q->state.prev_control_mode == 2) { + } else if (q->state.prev_control_mode == HERO_MODE_FALL) { q->swing_gravity = q->fall_state_gravity; } if (b) { @@ -854,7 +857,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ITEM_RELEASE_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 7; clear_u64_value(&p->motion.rot_spring_vel); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -879,14 +882,14 @@ int hero_set_state(int requested_state, int b) { int i; float f; float t; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 3; p->rand_timer.range = 0x68; p->grind_direction = 1; p->grind_yaw_offset = -1.5707964f; p->rail_off_frames = 0; p->grind_anim_variant = 0; - if (p->state.prev_control_mode != 0xF) { + if (p->state.prev_control_mode != HERO_MODE_GRIND) { p->unk5AC.i = 0; p->grind_pose = -1; p->grind_base_speed = 0.0f; @@ -907,7 +910,7 @@ int hero_set_state(int requested_state, int b) { fast_vec_sub(&d.v, &sampled_path_position, &p->motion.pos); if (0.001f < fast_vec_length(&d.v)) { fast_vec_normalize(&d.v, &d.v, 1.0f); - if (p->state.prev_control_mode != 0xF) { + if (p->state.prev_control_mode != HERO_MODE_GRIND) { p->grind_base_speed = fast_vec_dot(&p->motion.displacement, &d.v); } } @@ -935,7 +938,7 @@ int hero_set_state(int requested_state, int b) { int i; float f; float t; - p->state.control_mode = 0x1A; + p->state.control_mode = HERO_MODE_FOLLOW_PATH; p->unk2284 = 3; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -963,11 +966,11 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 24.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -983,7 +986,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -993,7 +996,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_LEDGE_SHIMMY_POSITIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (b) @@ -1002,7 +1005,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_LEDGE_SHIMMY_NEGATIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (b) @@ -1011,7 +1014,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (b) @@ -1021,7 +1024,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_FALL: case HERO_STATE_FATAL_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1060,7 +1063,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_DELAYED_JUMP_OR_R1_REPEAT_EXIT_WAIT: { struct Hero *p = &hero; int animation_transition = -2; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk22CA = 1; p->rand_timer.range = 0x68; p->unk2284 = 0; @@ -1076,7 +1079,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_LAND: { struct Hero *p = &hero; int landing_animation_transition = -2; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->rand_timer.range = 0x68; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { @@ -1114,7 +1117,7 @@ int hero_set_state(int requested_state, int b) { p->state_timer = p->state.prev_timer; return 0; } - p->state.control_mode = 4; + p->state.control_mode = HERO_MODE_JUMP; if (requested_state >= HERO_STATE_GRIND_JUMP && requested_state <= HERO_STATE_GRIND_RAIL_TRANSFER) { p->unk2284 = 3; @@ -1217,11 +1220,11 @@ int hero_set_state(int requested_state, int b) { u->unk498 = scale_game_frames(2); u->jump_max_frames = scale_game_frames(0x78); hero_change_health(1); - if (current_level_index == 0xA) { + if (current_level_index == LEVEL_ORXON) { hero_set_state(0x7C, 1); return 0; } - if (current_level_index != 6) { + if (current_level_index != LEVEL_NEBULA_G34) { if (u->state.prev == 0x3C || u->state.prev2 == 0x3C || u->health.hp == 0) { struct Hero *w = &hero; w->sink_jump_count = w->sink_jump_count + 1; @@ -1242,7 +1245,7 @@ int hero_set_state(int requested_state, int b) { } } else if (u->state.current == 0x69) { float v; - u->state.control_mode = 0x19; + u->state.control_mode = HERO_MODE_RESPAWN_WAIT; if (u->motion.pos.f[2] < u->sink_surface_z) { v = u->sink_surface_z - u->motion.pos.f[2]; } else { @@ -1271,7 +1274,7 @@ int hero_set_state(int requested_state, int b) { u->jump_height_start = 2.4f; u->unk498 = scale_game_frames(0x11); u->jump_gravity = frame_time_sq * 27.0f; - u->state.control_mode = 0xF; + u->state.control_mode = HERO_MODE_GRIND; u->rail_gap_jump = 0; if (u->selector_5 != 0) { float h = 4.7f; @@ -1301,7 +1304,7 @@ int hero_set_state(int requested_state, int b) { u->jump_height_start = 2.5f; u->unk498 = scale_game_frames(0xA); u->jump_gravity = frame_time_sq * 24.0f; - u->state.control_mode = 0xF; + u->state.control_mode = HERO_MODE_GRIND; u->rail_gap_jump = 0; } else if (u->state.current == 9) { u->unk430 = 1.0f; @@ -1549,7 +1552,7 @@ int hero_set_state(int requested_state, int b) { } else if (s == 0xA) { set_hero_animation(0x12, 0, (float)scale_game_frames(5)); } else if (s == 0x10) { - if (q->state.prev_control_mode == 4 || + if (q->state.prev_control_mode == HERO_MODE_JUMP || (q->state.prev == 4 && scale_game_frames(7) > q->state_timer)) { set_hero_animation(0x26, 0, (float)scale_game_frames(8)); q->takeoff_frame += scale_game_frames(3); @@ -1583,7 +1586,7 @@ int hero_set_state(int requested_state, int b) { } { struct Hero *w = &hero; - if (w->state.prev_control_mode == 4) { + if (w->state.prev_control_mode == HERO_MODE_JUMP) { set_hero_animation(id, 1, (float)scale_game_frames(4)); w->takeoff_frame = scale_game_frames(1); } else { @@ -1602,7 +1605,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_ANIMATION_RECOVERY_WITH_JUMP_CANCEL: case HERO_STATE_VEHICLE_MODE_1_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->speed_scale = 1.0f; p->unk2284 = 0; p->heading_locked = 0; @@ -1701,7 +1704,8 @@ int hero_set_state(int requested_state, int b) { e = &D_L17_0017C528[q->attack_record]; q->saved_item[0] = 0; k = 0; - if (q->state.prev_control_mode == 6 && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { + if (q->state.prev_control_mode == HERO_MODE_ATTACK && e->unk0 == 0 && + q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 3; } { @@ -1742,8 +1746,8 @@ int hero_set_state(int requested_state, int b) { struct Hero *q = &hero; HeroTableRow2C *e = &D_L17_0017C528[q->attack_record]; int k = 0; - if ((q->state.prev_control_mode == 6 || - (q->state.prev2_control_mode == 6 && + if ((q->state.prev_control_mode == HERO_MODE_ATTACK || + (q->state.prev2_control_mode == HERO_MODE_ATTACK && (unsigned int)(q->moby->prev_seq - 0xF) < 2)) && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 2; @@ -1782,7 +1786,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ATTACK_RECORD_FRAME_EXIT_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unkA64 = 0; if (p->state.prev == 0x70) { int v = 5; @@ -1809,7 +1813,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_GRIND_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unkA64 = 0; if (p->state.prev == 0x2B) { p->attack_record = p->attack_record == 0; @@ -1860,7 +1864,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_HURT: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->unk1EE = scale_game_frames(0x2D); @@ -1886,7 +1890,8 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_WAIT_FOR_JUMP_OR_RESPAWN: { struct Hero *p = &hero; if (p->state.prev == 0x69 || - (p->state.prev2 == 0x69 && p->state.prev_control_mode != 0 && p->state.prev != 7)) { + (p->state.prev2 == 0x69 && p->state.prev_control_mode != HERO_MODE_IDLE && + p->state.prev != 7)) { p->sink_jump_count = p->sink_jump_count + 1; } else { struct Hero *q = &hero; @@ -1894,7 +1899,7 @@ int hero_set_state(int requested_state, int b) { } { struct Hero *r = &hero; - r->state.control_mode = 0x19; + r->state.control_mode = HERO_MODE_RESPAWN_WAIT; r->unk2284 = 0; allocate_hero_voice_for_entry(9, 0); r->rand_timer.range = 0x68; @@ -1907,9 +1912,9 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_HEIGHT_OR_TIMEOUT_RESPAWN_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0x19; + p->state.control_mode = HERO_MODE_RESPAWN_WAIT; p->unk2284 = 0; - if (current_level_index == 0xF) + if (current_level_index == LEVEL_QUARTU) spawn_hero_radial_particle_burst(); p->collision_off_frames = 0x2710; allocate_hero_voice_for_entry(9, 0); @@ -1919,7 +1924,7 @@ int hero_set_state(int requested_state, int b) { break; } case HERO_STATE_DEATH_DESCENT: { - if (current_level_index == 6) { + if (current_level_index == LEVEL_NEBULA_G34) { int c0; int c1; int c2; @@ -1934,7 +1939,7 @@ int hero_set_state(int requested_state, int b) { } { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->collision_off_frames = 0x2710; @@ -1948,7 +1953,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_VEHICLE_MODE_1_DEATH_DESCENT: { struct Hero *p = &hero; char *m; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->collision_off_frames = 0x2710; @@ -1962,7 +1967,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_1_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (p->on_slip_ground != 0 && p->frames_off_ground.s == 0) { hero_set_state(0x52, 1); @@ -1974,7 +1979,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_1_LAND: { struct Hero *p = &hero; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { scale_hero_motion(frame_time * 4.5f / p->motion.speed_xy); @@ -1986,7 +1991,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_1_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->stickless_decel = frame_time_sq * 7.0f; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1996,7 +2001,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_1_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (b) @@ -2005,7 +2010,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_1_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -2028,12 +2033,12 @@ int hero_set_state(int requested_state, int b) { } { struct Hero *q = &hero; - q->state.control_mode = 1; + q->state.control_mode = HERO_MODE_RUN; q->unk2284 = 0; q->ground_speed = vector_length_xy(&q->motion.resolved_velocity); if (q->state.prev == 3) q->ground_speed = 0.0f; - if (q->state.prev_control_mode == 0) + if (q->state.prev_control_mode == HERO_MODE_IDLE) q->ground_speed = vector_length_xy(&q->motion.momentum); q->unk3B8 = 0; if (b) @@ -2043,7 +2048,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_1_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -2053,11 +2058,11 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ALT_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 12.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -2067,7 +2072,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ALT_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; if (b) set_hero_animation(0xA, 0, (float)scale_game_frames(6)); @@ -2075,7 +2080,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ALT_LEDGE_SHIMMY_YAW_PLUS_90: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; if (b) set_hero_animation(0xB, 0, (float)scale_game_frames(6)); @@ -2083,7 +2088,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ALT_LEDGE_SHIMMY_YAW_MINUS_90: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; if (b) set_hero_animation(0xC, 0, (float)scale_game_frames(6)); @@ -2091,7 +2096,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_3_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (b) set_hero_animation(0, 0, (float)scale_game_frames(0xE)); @@ -2099,7 +2104,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_DELAYED_CIRCLE_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (b) { set_hero_animation(4, 0, (float)scale_game_frames(7)); @@ -2109,7 +2114,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_3_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (b) @@ -2118,7 +2123,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_3_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -2129,7 +2134,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_3_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; { Vec4 *v = &p->motion.resolved_velocity; @@ -2147,7 +2152,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_3_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (b) @@ -2156,7 +2161,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_3_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -2172,7 +2177,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_GRIND_COLLISION_RECOVERY: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 0; if (p->rail_off_frames == 0) hero_change_health(1); @@ -2199,7 +2204,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_LOOK_RELEASE_WAIT: { struct Hero *p = &hero; p->unk2284 = 0x51; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; if (return_hero_animation_id_unchanged(p->moby->prev_seq) != select_hero_help_value(1)) { set_hero_animation(select_hero_help_value(1), 0, (float)scale_game_frames(5)); } @@ -2223,7 +2228,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_IDLE_ANIMATION_LONG_BLEND_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; set_hero_animation(select_hero_help_value(0), 0, (float)scale_game_frames(0xA)); break; @@ -2289,7 +2294,8 @@ int hero_set_state(int requested_state, int b) { } { struct Hero *t = &hero; - if (t->state.control_mode != 0xF && t->items[1].item_id == 0x1D && t->saved_item[1] != 0) { + if (t->state.control_mode != HERO_MODE_GRIND && t->items[1].item_id == 0x1D && + t->saved_item[1] != 0) { t->restore_item[1] = 1; } } @@ -2301,7 +2307,7 @@ int hero_set_state(int requested_state, int b) { } { struct Hero *t = &hero; - if (t->state.control_mode == 0x14) { + if (t->state.control_mode == HERO_MODE_DYING) { cancel_hero_item_animation(); t->item_use_locked = 1; } diff --git a/src/overlays/l17/hero/process_hero_hit_response.c b/src/overlays/l17/hero/process_hero_hit_response.c index 6f6f4eec8e..76b4ecdd68 100644 --- a/src/overlays/l17/hero/process_hero_hit_response.c +++ b/src/overlays/l17/hero/process_hero_hit_response.c @@ -85,10 +85,10 @@ s32 process_hero_hit_response(s32 apply_state_and_motion_response) { f32 xy_scale, z_response, frame_duration; OvlVec4 motion_delta; - if (G.state.control_mode == 0x14) { + if (G.state.control_mode == HERO_MODE_DYING) { return 0; } - if (G.state.control_mode == 7) { + if (G.state.control_mode == HERO_MODE_HURT) { return 0; } if (G.state.current == 0x32) { @@ -115,7 +115,7 @@ s32 process_hero_hit_response(s32 apply_state_and_motion_response) { D_0013DF88[current_level_index]++; G.damage_source_moby = (struct Moby *)hero_moby_entry->target; D_0015EEA8++; - if (G.state.control_mode == 0xF) { + if (G.state.control_mode == HERO_MODE_GRIND) { G.unk5BE = 1; return 0; } @@ -150,20 +150,20 @@ s32 process_hero_hit_response(s32 apply_state_and_motion_response) { G.motion.resolved_velocity_z.f[2] = frame_time * 7.0f; return 1; } - if (G.state.control_mode == 0x12) { + if (G.state.control_mode == HERO_MODE_WATER_SURFACE) { mob = (u8 *)G.damage_source_moby; if (mob != 0 && *(s16 *)(mob + 0xA6) == 0x28F) { id = 0x82; goto call_ret; } hero_set_state(0x75, 1); - } else if (G.state.control_mode == 0x11) { + } else if (G.state.control_mode == HERO_MODE_SWIM) { mob = (u8 *)G.damage_source_moby; if (mob != 0 && *(s16 *)(mob + 0xA6) == 0x28F) { id = 0x82; goto call_ret; } - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || current_level_index == LEVEL_VELDIN_ORBIT) { mob = (u8 *)G.damage_source_moby; if (mob != 0 && (*(s16 *)(mob + 0xA6) == 0x28F || *(s16 *)(mob + 0xA6) == 0x7B || *(s16 *)(mob + 0xA6) == 0x29D)) { @@ -171,7 +171,7 @@ s32 process_hero_hit_response(s32 apply_state_and_motion_response) { } } hero_set_state(0x76, 1); - } else if (G.state.control_mode == 3) { + } else if (G.state.control_mode == HERO_MODE_LEDGE) { mob = (u8 *)G.damage_source_moby; if (mob != 0) { id = 0x82; @@ -232,7 +232,7 @@ void update_hero_smoothing(void) { hero.capsule_radius_target = 0.45f; break; } - if (hero.state.control_mode == 4) { + if (hero.state.control_mode == HERO_MODE_JUMP) { if (hero.state_timer > hero.takeoff_frame && hero.past_jump_apex == 0) hero.capsule_bottom_target = hero.unk434; } else if (hero.state.current == HERO_STATE_FALL) { @@ -248,8 +248,8 @@ void update_hero_smoothing(void) { } else if (hero.state.current == HERO_STATE_SINK) { hero.capsule_radius_target = 0.8f; } - if (!hero.wall_hit || hero.state.prev_control_mode == 0x12 || hero.state.control_mode == 0x11 || - hero.base_condition || + if (!hero.wall_hit || hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE || + hero.state.control_mode == HERO_MODE_SWIM || hero.base_condition || vector_distance_xy(hero.wall_contact_point.f, hero.motion.pos.f) > hero.capsule_radius * 0.5f) { f32 *smoothing_state = D_0013F570; diff --git a/src/overlays/l17/hero/update_hero_motion_for_current_state.c b/src/overlays/l17/hero/update_hero_motion_for_current_state.c index 7ead070e20..073520bed8 100644 --- a/src/overlays/l17/hero/update_hero_motion_for_current_state.c +++ b/src/overlays/l17/hero/update_hero_motion_for_current_state.c @@ -1830,12 +1830,12 @@ void update_hero_motion_for_current_state(void) { f32 f; f32 old; f32 d; - if (current_level_index == 0xF) { + if (current_level_index == LEVEL_QUARTU) { release_voice_slot_cf(2, (struct MobyView *)hero.moby, 0x1D); } else { release_voice_slot_cf(2, (struct MobyView *)hero.moby, 6); } - if (current_level_index != 0xF) { + if (current_level_index != LEVEL_QUARTU) { emit_hero_randomized_motion_effects(4, 2); scratch_vector.f[0] = hero.motion.pos.f[0] + random_float_between(-0.25f, 0.25f); scratch_vector.f[1] = hero.motion.pos.f[1] + random_float_between(-0.25f, 0.25f); diff --git a/src/overlays/l17/hero/update_hero_state_transitions.c b/src/overlays/l17/hero/update_hero_state_transitions.c index b438a4f6a3..3f83f43b24 100644 --- a/src/overlays/l17/hero/update_hero_state_transitions.c +++ b/src/overlays/l17/hero/update_hero_state_transitions.c @@ -191,7 +191,7 @@ void update_hero_state_transitions(void) { prevState = hero.state.step; prevAnim = MOBY(moby)->prev_seq; if (process_hero_hit_response(1) == 0) { - if (hero.health.hp <= 0 && hero.state.control_mode != 0x14 && + if (hero.health.hp <= 0 && hero.state.control_mode != HERO_MODE_DYING && (hero.state.current == HERO_STATE_IDLE || hero.state.current == HERO_STATE_RUN)) { hero_set_state(HERO_STATE_DYING, 1); } else if (process_hero_equipped_item_input() == 0 && try_enter_hero_water_state() == 0 && @@ -470,7 +470,7 @@ void update_hero_state_transitions(void) { } } if (ok && 0.22f < hero.stick_magnitude) { - if (current_level_index == 0xC) { + if (current_level_index == LEVEL_HOVEN) { int slot = hero.ground_sound_class; emit_hero_animation_voice_and_ground_particle(slot, 0, 0); emit_hero_animation_voice_and_ground_particle(slot, 1, 0); @@ -661,7 +661,8 @@ void update_hero_state_transitions(void) { break; case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: if (hero.health.hp <= 0) { - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || + current_level_index == LEVEL_VELDIN_ORBIT) { hero_set_state(0x82, 1); break; } @@ -850,7 +851,8 @@ void update_hero_state_transitions(void) { break; } if (!(hero.air_frames.s < scale_game_frames(5)) && - !(hero.state.prev_control_mode == 0x12 && hero.wading != 0) && + !(hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE && + hero.wading != 0) && hero.ground_distance > 1.35f) { if (check_hero_forward_collision_height() == 0) { hero_set_state(HERO_STATE_FALL, 1); @@ -946,7 +948,8 @@ void update_hero_state_transitions(void) { break; } if (hero.state_timer > scale_game_frames(0xF) || - (hero.state.prev_control_mode != 0 && hero.state.prev_control_mode != 1)) { + (hero.state.prev_control_mode != HERO_MODE_IDLE && + hero.state.prev_control_mode != HERO_MODE_RUN)) { if ((controller_state.pressed & 0x10000) && hero.unk20AA == 0) { hero.unk3BE = 1; } @@ -1376,7 +1379,7 @@ void update_hero_state_transitions(void) { float len; grab = 0; - if (current_level_index == 0x10 && hero.wall_hit != 0) { + if (current_level_index == LEVEL_KALEBO3 && hero.wall_hit != 0) { unsigned char *m = ((unsigned char *)hero.coll_hit_moby); if (m != 0 && *(short *)(m + 0xA6) == 0x101) { grab = 1; @@ -1388,7 +1391,7 @@ void update_hero_state_transitions(void) { hero.unk5BE != 0) { int ok = 1; - if (current_level_index != 0x10) { + if (current_level_index != LEVEL_KALEBO3) { qcopy(query_position, hero.rail_point.f); query_position[2] += 2.0f; spatial_query_vector[0] = fast_cos(hero.rail_dir_yaw) * 5.0f; @@ -1439,7 +1442,7 @@ void update_hero_state_transitions(void) { if (hero.state.current == HERO_STATE_GRIND) { int go = 1; - if (current_level_index == 8) { + if (current_level_index == LEVEL_BATALIA) { *(OvlQuad *)query_position = 0; query_position[0] = 342.0f; query_position[1] = 111.1f; @@ -1964,9 +1967,9 @@ void update_hero_state_transitions(void) { } break; case HERO_STATE_FATAL_FALL: - if ((current_level_index == 3 && 5.0f > hero.motion.pos.f[2]) || - (current_level_index == 6 && 50.0f > hero.motion.pos.f[2]) || - (current_level_index == 0x10 && + if ((current_level_index == LEVEL_KERWAN && 5.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_NEBULA_G34 && 50.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_KALEBO3 && (77.0f > hero.motion.pos.f[2] || (hero.state_timer > 0x14 && hero.wall_hit != 0 && hero.motion.displacement.f[2] >= 0.0f))) || @@ -2477,8 +2480,8 @@ void update_hero_state_transitions(void) { hero_set_state(HERO_STATE_FALL, 1); break; } - if (current_level_index == 0x10 && 0.0f > hero.motion.velocity.f[2] && - hero.health.hp == 0 && hero.state.prev_control_mode == 0xF) { + if (current_level_index == LEVEL_KALEBO3 && 0.0f > hero.motion.velocity.f[2] && + hero.health.hp == 0 && hero.state.prev_control_mode == HERO_MODE_GRIND) { hero_set_state(0x77, 1); break; } @@ -2709,7 +2712,7 @@ void update_hero_state_transitions(void) { } break; case HERO_STATE_VEHICLE_MODE_1_FALL: - if (current_level_index == 6 && 115.0f > hero.motion.pos.f[2]) { + if (current_level_index == LEVEL_NEBULA_G34 && 115.0f > hero.motion.pos.f[2]) { goto respawn; } if (hero.air_frames.s == 0) { diff --git a/src/overlays/l17/render_level_sky.c b/src/overlays/l17/render_level_sky.c index 21041c893d..d2707b89de 100644 --- a/src/overlays/l17/render_level_sky.c +++ b/src/overlays/l17/render_level_sky.c @@ -12,7 +12,7 @@ void render_level_sky(void) __asm__("FUN_L17_00238c50"); void render_level_sky(void) { setup_sky_gif_paging(); - if (current_level_index == 0x11) { + if (current_level_index == LEVEL_VELDIN_ORBIT) { render_three_shell_particle_sky(); } else { update_sky_shells_static(); diff --git a/src/overlays/l18/draw_level_sky_shells.c b/src/overlays/l18/draw_level_sky_shells.c index 27b0088fc9..e042c3bd8c 100644 --- a/src/overlays/l18/draw_level_sky_shells.c +++ b/src/overlays/l18/draw_level_sky_shells.c @@ -11,7 +11,7 @@ void draw_level_sky_shells(void) __asm__("FUN_L18_00240840"); void draw_level_sky_shells(void) { setup_sky_gif_paging(); - if (current_level_index == 0x12) { + if (current_level_index == LEVEL_VELDIN2) { draw_seven_sky_shells_with_modulo_40000_and_60000_rotation(); } else { update_sky_shells_static(); diff --git a/src/overlays/l18/hero/apply_hero_ground_type_effects.c b/src/overlays/l18/hero/apply_hero_ground_type_effects.c index dd3a36b74a..6d706260a5 100644 --- a/src/overlays/l18/hero/apply_hero_ground_type_effects.c +++ b/src/overlays/l18/hero/apply_hero_ground_type_effects.c @@ -193,10 +193,10 @@ s32 process_hero_hurt_response(s32 apply_hurt_response) { f32 horizontal_response_scale, vertical_response_scale, response_frame_time; V_210ce8 response_motion_delta; - if (hero.state.control_mode == 0x14) { + if (hero.state.control_mode == HERO_MODE_DYING) { return 0; } - if (hero.state.control_mode == 7) { + if (hero.state.control_mode == HERO_MODE_HURT) { return 0; } if (hero.state.current == 0x32) { @@ -227,7 +227,7 @@ s32 process_hero_hurt_response(s32 apply_hurt_response) { D_0013DF88[current_level_index]++; hero.damage_source_moby = (struct Moby *)response_record->p20; D_0015EEA8++; - if (hero.state.control_mode == 0xF) { + if (hero.state.control_mode == HERO_MODE_GRIND) { hero.unk5BE = 1; return 0; } @@ -268,20 +268,20 @@ s32 process_hero_hurt_response(s32 apply_hurt_response) { hero.motion.resolved_velocity_z.f[2] = frame_time * 7.0f; return 1; } - if (hero.state.control_mode == 0x12) { + if (hero.state.control_mode == HERO_MODE_WATER_SURFACE) { mob = ((u8 *)hero.damage_source_moby); if (mob != 0 && *(s16 *)(mob + 0xA6) == 0x28F) { id = 0x82; goto call_ret; } hero_set_state(0x75, 1); - } else if (hero.state.control_mode == 0x11) { + } else if (hero.state.control_mode == HERO_MODE_SWIM) { mob = ((u8 *)hero.damage_source_moby); if (mob != 0 && *(s16 *)(mob + 0xA6) == 0x28F) { id = 0x82; goto call_ret; } - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || current_level_index == LEVEL_VELDIN_ORBIT) { mob = ((u8 *)hero.damage_source_moby); if (mob != 0 && (*(s16 *)(mob + 0xA6) == 0x28F || *(s16 *)(mob + 0xA6) == 0x7B || *(s16 *)(mob + 0xA6) == 0x29D)) { @@ -289,7 +289,7 @@ s32 process_hero_hurt_response(s32 apply_hurt_response) { } } hero_set_state(0x76, 1); - } else if (hero.state.control_mode == 3) { + } else if (hero.state.control_mode == HERO_MODE_LEDGE) { mob = ((u8 *)hero.damage_source_moby); if (mob != 0) { id = 0x82; diff --git a/src/overlays/l18/hero/hero_set_state.c b/src/overlays/l18/hero/hero_set_state.c index 802ad9b73e..7c8a8be7c7 100644 --- a/src/overlays/l18/hero/hero_set_state.c +++ b/src/overlays/l18/hero/hero_set_state.c @@ -76,7 +76,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { float grind_direction_or_jump_probe_position[4]; { struct Hero *p = &hero; - if (p->state.control_mode == 0x14 && + if (p->state.control_mode == HERO_MODE_DYING && (requested_state != HERO_STATE_IDLE_ANIMATION_WITH_DYING_OVERRIDE || animation_update_mode != 2)) return 0; @@ -85,7 +85,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { return 0; { struct Hero *p = &hero; - if (p->health.hp == 0 && (p->state.control_mode == 2 || p->state.control_mode == 7) && + if (p->health.hp == 0 && + (p->state.control_mode == HERO_MODE_FALL || p->state.control_mode == HERO_MODE_HURT) && requested_state != HERO_STATE_FALL && requested_state != HERO_STATE_DYING && requested_state != HERO_STATE_VEHICLE_MODE_1_DYING && requested_state != HERO_STATE_VEHICLE_MODE_3_DYING && @@ -136,7 +137,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { switch (requested_state) { case HERO_STATE_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; p->unk1010 = random_int_between(scale_game_frames(0x32), scale_game_frames(0x64)); clear_hero_idle_rotation_targets(); @@ -164,7 +165,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_AT_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; clear_u64_value(&p->motion.momentum); p->rand_timer.range = 0x68; @@ -190,7 +191,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (animation_update_mode) @@ -199,11 +200,11 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_SWIM: { struct Hero *p = &hero; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; *(int *)&p->drown_sink_speed = 0; - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } else { @@ -223,11 +224,11 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_SWIM_WITH_CROUCH_INPUT: { struct Hero *p = &hero; int n; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; p->unk8F4 = scale_game_frames(0x3C); - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } @@ -244,7 +245,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { struct Hero *p = &hero; int n; int t; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -259,11 +260,11 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_WATER_SURFACE_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; p->splash_effect_timer = 0; - if (p->state.prev_control_mode == 0x11) { + if (p->state.prev_control_mode == HERO_MODE_SWIM) { emit_hero_surface_effect_burst(3, 0xA, 0); if (D_L18_001612D0 != 0) { pool_splash(D_L18_001612D0, @@ -294,7 +295,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { { struct Hero *q = &hero; q->unk698 = 0; - if (q->state.prev_control_mode == 0x11) { + if (q->state.prev_control_mode == HERO_MODE_SWIM) { float d = (float)q->underwater_air; if (d < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); @@ -303,7 +304,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } { struct Hero *r = &hero; - if (r->state.prev_control_mode == 0x11) { + if (r->state.prev_control_mode == HERO_MODE_SWIM) { float e = (float)r->underwater_air; if (e < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); @@ -335,7 +336,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->item_select_blocked = 1; @@ -367,7 +368,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_WATER_SURFACE_MOVE: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; *(int *)&p->drown_sink_speed = 0; @@ -379,7 +380,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DROWN: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -419,7 +420,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DYING_ZERO_HEALTH: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -455,7 +456,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_LOOK: { struct Hero *p = &hero; int t; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 4; *(int *)&D_L18_0015F688 = scale_game_frames(0x3C); if (p->unk20AA == 0) { @@ -468,7 +469,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ITEM_BUTTON_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_help_value(0), 0, (float)scale_game_frames(0xA)); @@ -477,7 +478,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_WAIT_FOR_ITEM_RELEASE_THEN_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(get_hero_help_value(0), 0, (float)scale_game_frames(5)); @@ -486,7 +487,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ITEM_BUTTON_HOLD_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.displacement); p->state.step = 0; @@ -499,9 +500,10 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_DIRECTION_LIMITED_GROUND_MOVE: case HERO_STATE_SHALLOW_WATER_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; - if (p->state.prev_control_mode != 4 && p->state.prev2_control_mode != 4) { + if (p->state.prev_control_mode != HERO_MODE_JUMP && + p->state.prev2_control_mode != HERO_MODE_JUMP) { p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); } { @@ -512,7 +514,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { stick_target(1.0f, 0); if (1.5707964f < fast_difference_between_rotations(q->motion.rot.f[2], q->motion.move_yaw)) { - if (q->state.prev_control_mode == 7 || q->state.prev == 3 || q->state.prev2 == 3) { + if (q->state.prev_control_mode == HERO_MODE_HURT || q->state.prev == 3 || + q->state.prev2 == 3) { struct Hero *r = &hero; r->ground_speed = 0.0f; } @@ -548,7 +551,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { n = scale_game_frames(0x12); { struct Hero *u = &hero; - if (u->state.prev2_control_mode == 4 && + if (u->state.prev2_control_mode == HERO_MODE_JUMP && scale_game_frames(5) < u->rail_land_frames) n = scale_game_frames(0xD); } @@ -562,7 +565,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ANIMATION_FRAME_EXIT_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; if (animation_update_mode) { if (p->state.prev == 4) { @@ -575,7 +578,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_APPROACH_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->item_use_locked = 1; @@ -606,7 +609,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_STOP: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (p->on_slip_ground != 0 && p->frames_off_ground.s == 0) { @@ -634,7 +637,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_BRAKE_AT_TARGET_POSITION: { struct Hero *p = &hero; char *v = (char *)&p->motion.resolved_velocity; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = gravity_length_xy((float *)v); qcopy(&p->motion.momentum, v); @@ -649,7 +652,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_CROUCH: { struct Hero *p = &hero; - p->state.control_mode = 0xC; + p->state.control_mode = HERO_MODE_CROUCH; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); if (frame_time * 7.0f < p->ground_speed) @@ -678,7 +681,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_GRAPPLE_TARGET_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -700,7 +703,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_APPROACH_TARGET_MOBY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; *(int *)&p->grapple_pull_speed = 0; p->grapple_pull_ending = 0; @@ -711,7 +714,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_CONSTRAIN_TO_TARGET_RADIUS: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; p->item_use_locked = 1; *(int *)&p->grapple_pull_speed = 0; @@ -724,7 +727,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_GRAPPLE_SWING_ENTRY: { struct Hero *p = &hero; char *d; - p->state.control_mode = 0xE; + p->state.control_mode = HERO_MODE_GRAPPLE_SWING; p->unk2284 = 7; { struct UsageStat *h = (struct UsageStat *)item_usage; @@ -768,9 +771,9 @@ int hero_set_state(int requested_state, int animation_update_mode) { q->swing_target_moby->pos.y - q->motion.pos.f[1]); q->unk9A4 = fast_vec_dist(&q->motion.pos, &q->swing_target_moby->pos); q->swing_gravity = frame_time_sq * 27.0f; - if (q->state.prev_control_mode == 4) { + if (q->state.prev_control_mode == HERO_MODE_JUMP) { q->swing_gravity = q->jump_gravity; - } else if (q->state.prev_control_mode == 2) { + } else if (q->state.prev_control_mode == HERO_MODE_FALL) { q->swing_gravity = q->fall_state_gravity; } if (animation_update_mode) { @@ -785,7 +788,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ITEM_RELEASE_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 7; clear_u64_value(&p->motion.rot_spring_vel); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -810,14 +813,14 @@ int hero_set_state(int requested_state, int animation_update_mode) { float pos[4]; int seg; float t; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 3; p->rand_timer.range = 0x68; p->rail_off_frames = 0; p->grind_direction = 1; p->grind_yaw_offset = -1.5707964f; p->grind_anim_variant = 0; - if (p->state.prev_control_mode != 0xF) { + if (p->state.prev_control_mode != HERO_MODE_GRIND) { p->grind_pose = -1; p->unk5AC.i = 0; p->grind_base_speed = 0.0f; @@ -834,7 +837,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { fast_vec_normalize(grind_direction_or_jump_probe_position, grind_direction_or_jump_probe_position, 1.0f); - if (p->state.prev_control_mode != 0xF) { + if (p->state.prev_control_mode != HERO_MODE_GRIND) { p->grind_base_speed = fast_vec_dot(&p->motion.displacement, grind_direction_or_jump_probe_position); } @@ -864,11 +867,11 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 24.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -884,7 +887,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -894,7 +897,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_LEDGE_SHIMMY_POSITIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (animation_update_mode) @@ -903,7 +906,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_LEDGE_SHIMMY_NEGATIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (animation_update_mode) @@ -912,7 +915,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (animation_update_mode) @@ -922,7 +925,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_FALL: case HERO_STATE_FATAL_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -957,7 +960,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_DELAYED_JUMP_OR_R1_REPEAT_EXIT_WAIT: { struct Hero *p = &hero; int animation_transition_code = -2; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk22CA = 1; p->rand_timer.range = 0x68; p->unk2284 = 0; @@ -973,7 +976,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_LAND: { struct Hero *p = &hero; int animation_transition_code = -2; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->rand_timer.range = 0x68; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { @@ -1011,7 +1014,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { p->state_timer = p->state.prev_timer; return 0; } - p->state.control_mode = 4; + p->state.control_mode = HERO_MODE_JUMP; if (requested_state >= HERO_STATE_GRIND_JUMP && requested_state <= HERO_STATE_GRIND_RAIL_TRANSFER) { p->unk2284 = 3; @@ -1104,7 +1107,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } } else if (u->state.current == 0x69) { float v; - u->state.control_mode = 0x19; + u->state.control_mode = HERO_MODE_RESPAWN_WAIT; if (u->motion.pos.f[2] < u->sink_surface_z) { v = u->sink_surface_z - u->motion.pos.f[2]; } else { @@ -1132,7 +1135,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { u->unk48C = 2.45f; u->jump_height_start = 2.4f; u->unk498 = scale_game_frames(0x11); - u->state.control_mode = 0xF; + u->state.control_mode = HERO_MODE_GRIND; u->rail_gap_jump = 0; u->jump_gravity = frame_time_sq * 27.0f; if (u->selector_5 != 0) { @@ -1163,7 +1166,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { u->unk48C = 2.55f; u->jump_height_start = 2.5f; u->unk498 = scale_game_frames(0xA); - u->state.control_mode = 0xF; + u->state.control_mode = HERO_MODE_GRIND; u->rail_gap_jump = 0; u->jump_gravity = frame_time_sq * 24.0f; } else if (u->state.current == 9) { @@ -1400,7 +1403,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } else if (s == 0xA) { set_hero_animation(0x12, 0, (float)scale_game_frames(5)); } else if (s == 0x10) { - if (q->state.prev_control_mode == 4 || + if (q->state.prev_control_mode == HERO_MODE_JUMP || (q->state.prev == 4 && scale_game_frames(7) > q->state_timer)) { set_hero_animation(0x26, 0, (float)scale_game_frames(8)); q->takeoff_frame += scale_game_frames(3); @@ -1432,7 +1435,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } { struct Hero *w = &hero; - if (w->state.prev_control_mode == 4) { + if (w->state.prev_control_mode == HERO_MODE_JUMP) { set_hero_animation(id, 1, (float)scale_game_frames(4)); w->takeoff_frame = scale_game_frames(1); } else { @@ -1451,7 +1454,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_ANIMATION_RECOVERY_WITH_JUMP_CANCEL: case HERO_STATE_VEHICLE_MODE_1_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->speed_scale = 1.0f; p->unk2284 = 0; p->heading_locked = 0; @@ -1551,7 +1554,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { e = &D_L18_0017C628[q->attack_record]; q->saved_item[0] = 0; k = 0; - if (q->state.prev_control_mode == 6 && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { + if (q->state.prev_control_mode == HERO_MODE_ATTACK && e->unk0 == 0 && + q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 3; } { @@ -1606,7 +1610,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_ATTACK_RECORD_FRAME_EXIT_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unkA64 = 0; if (p->state.prev == 0x70) { int v = 5; @@ -1633,7 +1637,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_GRIND_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unkA64 = 0; if (p->state.prev == 0x2B) { p->attack_record = p->attack_record == 0; @@ -1684,7 +1688,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_HURT: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->unk1EE = scale_game_frames(0x2D); @@ -1710,7 +1714,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_WAIT_FOR_JUMP_OR_RESPAWN: { struct Hero *p = &hero; if (p->state.prev == 0x69 || - (p->state.prev2 == 0x69 && p->state.prev_control_mode != 0 && p->state.prev != 7)) { + (p->state.prev2 == 0x69 && p->state.prev_control_mode != HERO_MODE_IDLE && + p->state.prev != 7)) { p->sink_jump_count = p->sink_jump_count + 1; } else { struct Hero *q = &hero; @@ -1718,7 +1723,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } { struct Hero *r = &hero; - r->state.control_mode = 0x19; + r->state.control_mode = HERO_MODE_RESPAWN_WAIT; r->unk2284 = 0; allocate_hero_voice_for_entry(9, 0); r->rand_timer.range = 0x68; @@ -1731,9 +1736,9 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_HEIGHT_OR_TIMEOUT_RESPAWN_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0x19; + p->state.control_mode = HERO_MODE_RESPAWN_WAIT; p->unk2284 = 0; - if (current_level_index == 0xF) + if (current_level_index == LEVEL_QUARTU) spawn_hero_radial_particle_burst(); p->collision_off_frames = 0x2710; allocate_hero_voice_for_entry(9, 0); @@ -1744,7 +1749,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_2_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (animation_update_mode) set_hero_animation(0, 0, (float)scale_game_frames(0xF)); @@ -1752,7 +1757,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_2_REPEATABLE_SQUARE_ACTION: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unk2284 = 0; if (p->state.prev == 0x60 || (p->state.prev2 == 0x60 && scale_game_frames(0xA) > p->state.prev_timer)) { @@ -1773,7 +1778,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_2_COOLDOWN_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unk2284 = 0; if (animation_update_mode) set_hero_animation(0xC, 0, (float)scale_game_frames(8)); @@ -1781,7 +1786,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_WAIT_FOR_CIRCLE_RELEASE_AND_ANIMATION: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unk2284 = 0; if (animation_update_mode) set_hero_animation(8, 0, (float)scale_game_frames(8)); @@ -1789,7 +1794,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_2_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1805,7 +1810,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_2_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->unk3B8 = 0; @@ -1815,7 +1820,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_2_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (animation_update_mode) @@ -1824,7 +1829,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_2_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1839,7 +1844,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (animation_update_mode) set_hero_animation(0, 0, (float)scale_game_frames(0xE)); @@ -1847,7 +1852,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_DELAYED_CIRCLE_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (animation_update_mode) { set_hero_animation(4, 0, (float)scale_game_frames(7)); @@ -1857,7 +1862,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (animation_update_mode) @@ -1866,7 +1871,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1877,7 +1882,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; { char *v = (char *)&p->motion.resolved_velocity; @@ -1895,7 +1900,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (animation_update_mode) @@ -1904,7 +1909,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_VEHICLE_MODE_3_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1920,7 +1925,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_GRIND_COLLISION_RECOVERY: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 0; if (p->rail_off_frames == 0) hero_change_health(1); @@ -1947,7 +1952,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { case HERO_STATE_LOOK_RELEASE_WAIT: { struct Hero *p = &hero; p->unk2284 = 0x51; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; if (return_hero_animation_id_unchanged(p->moby->prev_seq) != get_hero_help_value(1)) { set_hero_animation(get_hero_help_value(1), 0, (float)scale_game_frames(5)); } @@ -1971,7 +1976,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } case HERO_STATE_IDLE_ANIMATION_LONG_BLEND_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; set_hero_animation(get_hero_help_value(0), 0, (float)scale_game_frames(0xA)); break; @@ -2037,7 +2042,8 @@ int hero_set_state(int requested_state, int animation_update_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode != 0xF && t->items[1].item_id == 0x1D && t->saved_item[1] != 0) { + if (t->state.control_mode != HERO_MODE_GRIND && t->items[1].item_id == 0x1D && + t->saved_item[1] != 0) { t->restore_item[1] = 1; } } @@ -2049,7 +2055,7 @@ int hero_set_state(int requested_state, int animation_update_mode) { } { struct Hero *t = &hero; - if (t->state.control_mode == 0x14) { + if (t->state.control_mode == HERO_MODE_DYING) { cancel_hero_item_animation(); t->item_use_locked = 1; } diff --git a/src/overlays/l18/hero/process_hero_state_transitions.c b/src/overlays/l18/hero/process_hero_state_transitions.c index 5166d486a4..b0dc3e798d 100644 --- a/src/overlays/l18/hero/process_hero_state_transitions.c +++ b/src/overlays/l18/hero/process_hero_state_transitions.c @@ -188,7 +188,7 @@ void process_hero_state_transitions(void) { prevState = hero.state.step; prevAnim = MOBY(moby)->prev_seq; if (process_hero_hurt_response(1) == 0) { - if (hero.health.hp <= 0 && hero.state.control_mode != 0x14 && + if (hero.health.hp <= 0 && hero.state.control_mode != HERO_MODE_DYING && (hero.state.current == HERO_STATE_IDLE || hero.state.current == HERO_STATE_RUN)) { hero_set_state(HERO_STATE_DYING, 1); } else if (process_hero_item_action_input() == 0 && try_enter_hero_water_state() == 0 && @@ -444,7 +444,7 @@ void process_hero_state_transitions(void) { } } if (ok && 0.22f < hero.stick_magnitude) { - if (current_level_index == 0xC) { + if (current_level_index == LEVEL_HOVEN) { int slot = hero.ground_sound_class; request_hero_voice_if_enabled(slot, 0, 0); request_hero_voice_if_enabled(slot, 1, 0); @@ -628,7 +628,8 @@ void process_hero_state_transitions(void) { break; case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: if (hero.health.hp <= 0) { - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || + current_level_index == LEVEL_VELDIN_ORBIT) { hero_set_state(0x82, 1); break; } @@ -814,7 +815,8 @@ void process_hero_state_transitions(void) { break; } if (!(hero.air_frames.s < scale_game_frames(5)) && - !(hero.state.prev_control_mode == 0x12 && hero.wading != 0) && + !(hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE && + hero.wading != 0) && hero.ground_distance > 1.35f) { if (check_hero_forward_collision_height() == 0) { hero_set_state(HERO_STATE_FALL, 1); @@ -881,7 +883,8 @@ void process_hero_state_transitions(void) { break; } if (hero.state_timer > scale_game_frames(0xF) || - (hero.state.prev_control_mode != 0 && hero.state.prev_control_mode != 1)) { + (hero.state.prev_control_mode != HERO_MODE_IDLE && + hero.state.prev_control_mode != HERO_MODE_RUN)) { if ((controller_state.pressed & 0x10000) && hero.unk20AA == 0) { hero.unk3BE = 1; } @@ -1264,7 +1267,7 @@ void process_hero_state_transitions(void) { } else { int ice = 0; - if (current_level_index == 0x10 && hero.wall_hit != 0 && + if (current_level_index == LEVEL_KALEBO3 && hero.wall_hit != 0 && ((unsigned char *)hero.coll_hit_moby) != 0 && *(short *)(((unsigned char *)hero.coll_hit_moby) + 0xA6) == 0x101) { ice = 1; @@ -1275,7 +1278,7 @@ void process_hero_state_transitions(void) { ice || hero.unk5BE != 0) { int ok = 1; - if (current_level_index != 0x10) { + if (current_level_index != LEVEL_KALEBO3) { qcopy(temporary_position, hero.rail_point.f); temporary_position[2] += 2.0f; trajectory_and_probe_workspace[0] = @@ -1333,7 +1336,7 @@ void process_hero_state_transitions(void) { if (hero.state.current == HERO_STATE_GRIND) { int can = 1; - if (current_level_index == 8) { + if (current_level_index == LEVEL_BATALIA) { *(OvlQuad *)temporary_position = 0; temporary_position[0] = 342.0f; temporary_position[1] = 111.1f; @@ -1843,9 +1846,9 @@ void process_hero_state_transitions(void) { } break; case HERO_STATE_FATAL_FALL: - if ((current_level_index == 3 && 5.0f > hero.motion.pos.f[2]) || - (current_level_index == 6 && 50.0f > hero.motion.pos.f[2]) || - (current_level_index == 0x10 && + if ((current_level_index == LEVEL_KERWAN && 5.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_NEBULA_G34 && 50.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_KALEBO3 && (77.0f > hero.motion.pos.f[2] || (hero.state_timer > 0x14 && hero.wall_hit != 0 && hero.motion.displacement.f[2] >= 0.0f))) || @@ -2352,8 +2355,8 @@ void process_hero_state_transitions(void) { hero_set_state(HERO_STATE_FALL, 1); break; } - if (current_level_index == 0x10 && hero.motion.velocity.f[2] < 0.0f && - hero.health.hp == 0 && hero.state.prev_control_mode == 0xF) { + if (current_level_index == LEVEL_KALEBO3 && hero.motion.velocity.f[2] < 0.0f && + hero.health.hp == 0 && hero.state.prev_control_mode == HERO_MODE_GRIND) { hero_set_state(0x77, 1); break; } diff --git a/src/overlays/l18/hero/update_hero_motion_for_current_state.c b/src/overlays/l18/hero/update_hero_motion_for_current_state.c index 04675e7b15..df86458614 100644 --- a/src/overlays/l18/hero/update_hero_motion_for_current_state.c +++ b/src/overlays/l18/hero/update_hero_motion_for_current_state.c @@ -1765,12 +1765,12 @@ void update_hero_motion_for_current_state(void) { f32 f; f32 old; f32 d; - if (current_level_index == 0xF) { + if (current_level_index == LEVEL_QUARTU) { release_voice_slot_cf(2, (struct MobyView *)hero.moby, 0x1D); } else { release_voice_slot_cf(2, (struct MobyView *)hero.moby, 6); } - if (current_level_index != 0xF) { + if (current_level_index != LEVEL_QUARTU) { emit_hero_randomized_motion_effects(4, 2); general_vector_or_hit_descriptor_scratch.f[0] = hero.motion.pos.f[0] + random_float_between(-0.25f, 0.25f); diff --git a/src/overlays/l18/mobys/drek_final_boss_robot.c b/src/overlays/l18/mobys/drek_final_boss_robot.c index 5b5933cd57..491f18a944 100644 --- a/src/overlays/l18/mobys/drek_final_boss_robot.c +++ b/src/overlays/l18/mobys/drek_final_boss_robot.c @@ -1213,7 +1213,7 @@ void drek_final_boss_robot_update(BossMoby *moby) { } else { qcopy(position_and_displacement_scratch, boss_data->f70); } - if (hero.state.control_mode == 0xF) { + if (hero.state.control_mode == HERO_MODE_GRIND) { qcopy(position_displacement_direction_and_rotation_scratch, D_L18_001600EC + boss_data->arena_center_node_index * 0x80 + 0x30); fast_vec_sub(position_and_displacement_scratch, @@ -1481,11 +1481,11 @@ void drek_final_boss_robot_update(BossMoby *moby) { } fire = 0; if (fast_dec_timer(&boss_data->action_frame_counter) != 0 && - (hero.state.control_mode != 0xF || + (hero.state.control_mode != HERO_MODE_GRIND || fast_dec_timer(&boss_data->secondary_action_timer_frames) != 0)) { fire = 1; } - if (hero.state.control_mode == 0xF) { + if (hero.state.control_mode == HERO_MODE_GRIND) { int *list = ((int *)hero.rail_spline); if (vector_distance_xy(hero.motion.pos.f, (char *)list + *list * 16) < 3.0f) { @@ -1928,7 +1928,7 @@ void update_drek_boss_damage_and_phase_transitions(char *moby) { step = step * 3.0f; } } - if (hero.state.control_mode == 0xF) { + if (hero.state.control_mode == HERO_MODE_GRIND) { *(float *)(boss_data + 0x390) = *(float *)(boss_data + 0x390) + step; } else { *(float *)(boss_data + 0x394) = *(float *)(boss_data + 0x394) + step; @@ -2307,7 +2307,7 @@ void update_drek_boss_arena_circling_movement(struct Moby *moby) { &((ArenaNode *)D_L18_001600EC)[boss_circle_vars->node].center) > drek_boss_default_circling_radius_gp + 1.0f) { speed = 10.0f; - } else if (hero.state.control_mode != 0xF) { + } else if (hero.state.control_mode != HERO_MODE_GRIND) { near = drek_boss_circling_base_near_hero_distance_gp; far = drek_boss_circling_base_far_hero_distance_gp; slow = drek_boss_circling_default_far_hero_speed_gp; diff --git a/src/overlays/l18/mobys/gadgebot.c b/src/overlays/l18/mobys/gadgebot.c index 3e1779816e..c45ca337d8 100644 --- a/src/overlays/l18/mobys/gadgebot.c +++ b/src/overlays/l18/mobys/gadgebot.c @@ -397,7 +397,7 @@ void update_gadgebot_damage_target_and_glow(struct Moby *moby) { (int *)(reaction_value_or_path_address + 0x10), *(int *)reaction_value_or_path_address); if (sentry_vars->target_mode == GADGEBOT_TARGET_HERO) { - if (hero.state.control_mode == 0xF) { + if (hero.state.control_mode == HERO_MODE_GRIND) { int *list = (int *)hero.rail_spline; qcopy(&sentry_vars->target, (char *)list + *list * 16); } else { diff --git a/src/overlays/l18/mobys/grind_rail_junction.c b/src/overlays/l18/mobys/grind_rail_junction.c index 02fe1cc00a..6730a44494 100644 --- a/src/overlays/l18/mobys/grind_rail_junction.c +++ b/src/overlays/l18/mobys/grind_rail_junction.c @@ -90,7 +90,7 @@ void grind_rail_junction_update(struct Moby *moby) { case STATE_SELECT_NEARER_PATH: hero.rail_catch_grace = 5; for (k = 0; k < 4; k++) { - if (hero.state.control_mode == 0xF && + if (hero.state.control_mode == HERO_MODE_GRIND && (hero.rail_spline == (s32)path_junction_vars->pair[k].first->path || hero.rail_spline == (s32)path_junction_vars->pair[k].second->path)) { continue; diff --git a/src/overlays/l18/mobys/thruster_pack_lock_red.c b/src/overlays/l18/mobys/thruster_pack_lock_red.c index 5a458f4020..d2c3bf1ce1 100644 --- a/src/overlays/l18/mobys/thruster_pack_lock_red.c +++ b/src/overlays/l18/mobys/thruster_pack_lock_red.c @@ -122,7 +122,7 @@ void thruster_pack_lock_red_update(struct Moby *moby) { moby->state = STATE_SETTLE_DEPRESSED_HEIGHT; moby->command = 1; moby->pos.z -= 1.5f; - if (current_level_index == 0x12) + if (current_level_index == LEVEL_VELDIN2) menu_item_enabled_115 = 1; } if (vector_distance_xy(&moby->pos, &hero.motion.pos) < 2.5f) { diff --git a/src/overlays/shared/camera/follow_camera_setup.c b/src/overlays/shared/camera/follow_camera_setup.c index a3918d09bb..f4a39825a0 100644 --- a/src/overlays/shared/camera/follow_camera_setup.c +++ b/src/overlays/shared/camera/follow_camera_setup.c @@ -277,11 +277,11 @@ void follow_camera_apply_overrides(O_2e6000 *camera_moby) { direction_or_rotation_deltas, 0.20943952f, direction_or_rotation_deltas[2]); follow_camera_start_slide(); } - if (hero.state.control_mode == 0x11) { + if (hero.state.control_mode == HERO_MODE_SWIM) { camera_moby->m->target_offset_scale = 0.25f; follow_camera_set_height(0.5f, 0.003f); } - if (hero.state.control_mode == 5) { + if (hero.state.control_mode == HERO_MODE_LAND) { flag = 1; { S40 *camera_target = (S40 *)((u8 *)camera_moby->m + 0x40); @@ -318,7 +318,7 @@ void follow_camera_apply_overrides(O_2e6000 *camera_moby) { camera_spring_state->f3C = follow_camera_vehicle_collision_probe_scale_gp; camera_spring_state->f44 = follow_camera_vehicle_collision_probe_step_growth_factor_gp; } - if (hero.unk20AA != 0 && hero.state.control_mode != 0xF) { + if (hero.unk20AA != 0 && hero.state.control_mode != HERO_MODE_GRIND) { set_follow_camera_orbit_clamp_mode(0); follow_camera_start_slide(); follow_camera_set_lateral_spring(0.04f, 0.2f); @@ -444,7 +444,7 @@ void rebuild_follow_camera_pose(int snap) __asm__("FUN_L00_002e66b8"); void rebuild_follow_camera_pose(int snap) { LevelCamera *cams = &l00_camera; - char *camera_moby = ((char *)cams->unk180); + char *camera_moby = ((char *)cams->current_camera); char *track = &cams->unk190; /* the followed player: position at 0, up vector at 0x30 */ char *follow_camera_state = *(char **)(camera_moby + 0x70); char *orbit = follow_camera_state + 0x130; /* distance at 0x2C, height at 0x30 */ @@ -950,7 +950,7 @@ int update_follow_camera_orbit_after_collision(unsigned char *camera_moby, *(short *)(B + 0x34) = scale_game_frames(0x884); } k = D_L00_00161CC8_gp; - if (!skip_previous_length_clamp && hero.state.control_mode != 2 && + if (!skip_previous_length_clamp && hero.state.control_mode != HERO_MODE_FALL && previous_orbit_length < adjusted_orbit_length) { fast_vec_scale(A, A, previous_orbit_length / adjusted_orbit_length); *(float *)(B + 0x30) = *(float *)(A + 0x2C) - previous_orbit_length; diff --git a/src/overlays/shared/camera/follow_camera_springs.c b/src/overlays/shared/camera/follow_camera_springs.c index 9aa2d9d5eb..4bd84aa97e 100644 --- a/src/overlays/shared/camera/follow_camera_springs.c +++ b/src/overlays/shared/camera/follow_camera_springs.c @@ -844,7 +844,7 @@ void update_follow_camera_attach_mode(char *camera) { if (attach_state->state == CAM_ATTACH_DEFAULT_PROJECT_HERO_FOCUS_VELOCITY) { struct Hero *player = &hero; - if (player->state.control_mode == 2) { + if (player->state.control_mode == HERO_MODE_FALL) { attach_state->prev = attach_state->state; attach_state->state = CAM_ATTACH_HERO_POSITION_BASE; attach_state->timer = l00_follow_camera_ground_focus_exit_transition_frames_gp; @@ -911,7 +911,7 @@ void update_follow_camera_attach_mode(char *camera) { qcopy(attach_state->v20, attach_state->v10); } else { struct Hero *control_mode_player = &hero; - if (control_mode_player->state.control_mode == 4 && + if (control_mode_player->state.control_mode == HERO_MODE_JUMP && D_L00_00166EEC == 0.0f) { attach_state->prev = attach_state->state; attach_state->state = CAM_ATTACH_GROUND_AWARE_FOCUS_VELOCITY; @@ -970,7 +970,7 @@ void update_follow_camera_attach_mode(char *camera) { qcopy(attach_state->v20, attach_state->v10); return; } - if (p->state.control_mode == 2) { + if (p->state.control_mode == HERO_MODE_FALL) { attach_state->prev = attach_state->state; attach_state->state = CAM_ATTACH_HERO_POSITION_BASE; attach_state->timer = @@ -1048,13 +1048,15 @@ void update_follow_camera_attach_mode(char *camera) { } if (attach_state->state == CAM_ATTACH_BLEND_PROJECTED_HERO_FOCUS_VELOCITY) { struct Hero *p = &hero; - if (p->state.control_mode == 2 || p->frames_off_ground.s >= scale_game_frames(0x37)) { + if (p->state.control_mode == HERO_MODE_FALL || + p->frames_off_ground.s >= scale_game_frames(0x37)) { goto to_one; } } if (attach_state->state == CAM_ATTACH_CONTINUE_BLEND_PROJECTED_HERO_FOCUS_VELOCITY) { struct Hero *p = &hero; - if (p->state.control_mode == 2 || p->frames_off_ground.s >= scale_game_frames(0x37)) { + if (p->state.control_mode == HERO_MODE_FALL || + p->frames_off_ground.s >= scale_game_frames(0x37)) { float r; to_one: attach_state->prev = attach_state->state; diff --git a/src/overlays/shared/camera/hero_aligned_camera.c b/src/overlays/shared/camera/hero_aligned_camera.c index 8bf0216795..d400f85ec6 100644 --- a/src/overlays/shared/camera/hero_aligned_camera.c +++ b/src/overlays/shared/camera/hero_aligned_camera.c @@ -312,7 +312,7 @@ void update_hero_aligned_camera_from_input(u8 *camera_object) { camera_rotation_state = *(S_9f38 **)(camera_object + 0x70); update_hero_aligned_camera_position(camera_object); FUN_001f9bf8_c(&up, ((u8 *)hero.moby) + 0xE0, 1.0f); - if (l00_camera.unk270 == 0 && hero.unk20A5 == 0) + if (l00_camera.transition_mode == 0 && hero.unk20A5 == 0) hero.unk20A5 = 1; rotation_input_target = -controller_state.analog[2]; if (rotation_input_target == 0.0f) @@ -344,7 +344,7 @@ void update_hero_aligned_camera_from_input(u8 *camera_object) { rotation_input_target = convert_integer_to_float((controller_state.held >> 12) & 1); if (rotation_input_target == 0.0f) rotation_input_target = -convert_integer_to_float((controller_state.held >> 14) & 1); - if (l00_camera.unk270 != 0 && hero.state.prev == 2) + if (l00_camera.transition_mode != 0 && hero.state.prev == 2) rotation_input_target = 0.0f; if (invert52 == 0) rotation_input_target = -rotation_input_target; @@ -523,10 +523,10 @@ void initialize_hero_aligned_camera_mode(void) __asm__("FUN_L00_002ea7a0"); void initialize_hero_aligned_camera_mode(void) { LevelCamera *shared_camera_globals = &l00_camera; LevelCamera *camera_globals; - if (shared_camera_globals->unk270 == 0) - shared_camera_globals->unk270 = 1; + if (shared_camera_globals->transition_mode == 0) + shared_camera_globals->transition_mode = 1; else - shared_camera_globals->unk270 = 2; + shared_camera_globals->transition_mode = 2; camera_globals = &l00_camera; camera_globals->unk273 = 0; camera_globals->unk294 = 0.05f; @@ -549,7 +549,7 @@ void select_camera_mode_by_hero_vector_alignment(A_2ea810 *camera_object) { if (hero.unk2284 == 0x51 || hero.unk2284 == 4) { return; } - if (Q.unk270 == 0) { + if (Q.transition_mode == 0) { Q.unk273 = 0; camera_object->selected_camera_mode = 2; Q.unk294 = 0.018f; @@ -571,7 +571,7 @@ void select_camera_mode_by_hero_vector_alignment(A_2ea810 *camera_object) { fast_arc_sin(FUN_001f9ab0_2ea810(hero_vector_residual, camera_vector_residual) / residual_length_product); if (1.5707964f - dot_product_or_asin_result >= 1.3962634f) { - Q.unk270 = 0; + Q.transition_mode = 0; camera_object->selected_camera_mode = 4; return; } diff --git a/src/overlays/shared/camera/hoverboard_camera.c b/src/overlays/shared/camera/hoverboard_camera.c index e3a42e64c1..1de31f87a2 100644 --- a/src/overlays/shared/camera/hoverboard_camera.c +++ b/src/overlays/shared/camera/hoverboard_camera.c @@ -35,7 +35,7 @@ void update_hero_follow_camera_focus(char *moby) { transform_vector(hero_focus_offset, hero_focus_offset, &hero); fast_vec_add(focus_position, &hero.motion.pos, hero_focus_offset); qcopy(orbit + 0x1D0, focus_position); - if (current_level_index == 5) { + if (current_level_index == LEVEL_RILGAR) { float height_reference_position[4]; *(OvlQuad *)height_reference_position = 0; height_reference_position[0] = 286.16f; @@ -51,7 +51,7 @@ void update_hero_follow_camera_focus(char *moby) { focus_position[2] = 67.2f; } } - } else if (current_level_index == 0x10) { + } else if (current_level_index == LEVEL_KALEBO3) { if (focus_position[2] < 77.5f) { focus_position[2] = 77.5f; } diff --git a/src/overlays/shared/camera/init_camera_system.c b/src/overlays/shared/camera/init_camera_system.c index be64ec9d36..9a059b0851 100644 --- a/src/overlays/shared/camera/init_camera_system.c +++ b/src/overlays/shared/camera/init_camera_system.c @@ -81,8 +81,8 @@ typedef struct { void initialize_camera_record_handoff_defaults(void) __asm__("FUN_L00_001eb448"); void initialize_camera_record_handoff_defaults(void) { - ((T001eb448 *)l00_camera.unk180)->h = 1; - ((T001eb448 *)l00_camera.unk180)->b = 0; + ((T001eb448 *)l00_camera.current_camera)->h = 1; + ((T001eb448 *)l00_camera.current_camera)->b = 0; } extern struct CameraType level_camera_types[] __asm__("D_L00_001EA880"); @@ -123,19 +123,20 @@ void init_camera_system(void) { float *camera_vector_snapshot, *camera_record_vector_destination, *vector_copy_source, *vector_copy_destination; char *current_camera_record; - if (((char *)camera_system_state->unk180) != 0) { - *(short *)(((char *)camera_system_state->unk180) + 0x8E) = 0; - *(((char *)camera_system_state->unk180) + 0x7D) = 0; - *(short *)(((char *)camera_system_state->unk180) + 0x7E) = 0; + if (((char *)camera_system_state->current_camera) != 0) { + *(short *)(((char *)camera_system_state->current_camera) + 0x8E) = 0; + *(((char *)camera_system_state->current_camera) + 0x7D) = 0; + *(short *)(((char *)camera_system_state->current_camera) + 0x7E) = 0; } - camera_system_state->unk180 = find_camera_record_by_id(0); - *(short *)(((char *)camera_system_state->unk180) + 0x8E) = 1; - *(char **)(((char *)camera_system_state->unk180) + 0x70) = active_camera_saved_state_storage; - camera_system_state->unk270 = 0; + camera_system_state->current_camera = find_camera_record_by_id(0); + *(short *)(((char *)camera_system_state->current_camera) + 0x8E) = 1; + *(char **)(((char *)camera_system_state->current_camera) + 0x70) = + active_camera_saved_state_storage; + camera_system_state->transition_mode = 0; update_camera_tracking_state(); - camera_run_setup_to_new_cam(((char *)camera_system_state->unk180)); + camera_run_setup_to_new_cam(((char *)camera_system_state->current_camera)); backup_current_cam(); - current_camera_record = ((char *)camera_system_state->unk180); + current_camera_record = ((char *)camera_system_state->current_camera); camera_vector_snapshot = (float *)(&camera_system_state->pos); qcopy(camera_vector_snapshot, current_camera_record + 0x30); camera_record_vector_destination = (float *)(current_camera_record + 0x64); @@ -193,8 +194,8 @@ void setup_level_cameras(void) { int i; int k; - camera_system_state->unk394 = 0; - camera_system_state->unk398 = 0; + camera_system_state->underwater = 0; + camera_system_state->frame_count = 0; D_L00_0015EF40_gp = 0.75f; D_L00_0015EF4C = 0; for (k = 0; k < 48; k++) { @@ -205,8 +206,8 @@ void setup_level_cameras(void) { hero_state = &hero; q = &camera_system_state_alias->unk190; normalized_hero_vector = &camera_system_state_alias->unk190[32]; - *(int *)&camera_system_state_alias->unk184 = 0; - camera_system_state_alias->unk270 = 0; + *(int *)&camera_system_state_alias->previous_camera = 0; + camera_system_state_alias->transition_mode = 0; fast_vec_normalize(normalized_hero_vector, (char *)(((int)hero_state->moby) + 0xE0), 1.0f); qcopy(&camera_system_state_alias->unk1C0, normalized_hero_vector); qcopy(&camera_system_state_alias->unk1D0, normalized_hero_vector); @@ -336,7 +337,7 @@ void resolve_camera_movement_collisions(OvlQuad *camera_pos void resolve_camera_movement_collisions(OvlQuad *camera_position, float collision_radius) { OvlQuad step_delta[1]; float camera_movement_origin_snapshot[4] __attribute__((aligned(16))); - char *camera_record_at_entry = (char *)l00_camera_lui.unk180; + char *camera_record_at_entry = (char *)l00_camera_lui.current_camera; float *camera_movement_origin = (float *)(camera_record_at_entry + 0x64); int step_count, i, j; @@ -363,7 +364,7 @@ void resolve_camera_movement_collisions(OvlQuad *camera_position, float collisio j++) { qcopy(camera_position, &coll_hit_position); { - char *current_camera_record = (char *)l00_camera_lui.unk180; + char *current_camera_record = (char *)l00_camera_lui.current_camera; if (*(unsigned char *)(current_camera_record + 0x89) == 0) { *(unsigned char *)(current_camera_record + 0x89) = 1; } diff --git a/src/overlays/shared/camera/scripted_camera.c b/src/overlays/shared/camera/scripted_camera.c index 80af3f9737..93769374f0 100644 --- a/src/overlays/shared/camera/scripted_camera.c +++ b/src/overlays/shared/camera/scripted_camera.c @@ -134,7 +134,7 @@ void jet_end_mount(int mode) { JET_END_MOUNT_REPOSITION_BEHIND_HERO = 0 }; LevelCamera *camera_globals = &l00_camera_lui; - char *current_follow_camera = ((char *)camera_globals->unk180); + char *current_follow_camera = ((char *)camera_globals->current_camera); initialize_camera_record_handoff_defaults(); if (mode == JET_END_MOUNT_REPOSITION_BEHIND_HERO) { float camera_up_offset[4] __attribute__((aligned(16))); @@ -148,7 +148,7 @@ void jet_end_mount(int mode) { FUN_001f9bf8_2eac18(camera_up_offset, &hero_rotation_matrix[8], 1.2f); FUN_001f9a10_2eac18(camera_position, hero_rotation - 0x10, camera_up_offset); FUN_001f9a10_2eac18(camera_position, camera_position, camera_backward_offset); - *(short *)(((char *)camera_globals->unk180) + 0x8A) = 1; + *(short *)(((char *)camera_globals->current_camera) + 0x8A) = 1; } else if (mode == 2) { *(char *)&camera_globals->unk273 = 0; *(short *)(current_follow_camera + 0x7E) = 2; diff --git a/src/overlays/shared/camera/swing_volume_camera.c b/src/overlays/shared/camera/swing_volume_camera.c index 363f537b39..524416d657 100644 --- a/src/overlays/shared/camera/swing_volume_camera.c +++ b/src/overlays/shared/camera/swing_volume_camera.c @@ -198,10 +198,11 @@ void volume_camera_swing(struct UpdateCam *swing_camera_record) { if (params->timer == 0) { LevelCamera *camera_globals = &l00_camera; params->start_lateral_stiffness = - FOLLOW_CAM_STATE(((struct UpdateCam *)camera_globals->unk180)) + FOLLOW_CAM_STATE(((struct UpdateCam *)camera_globals->current_camera)) ->follow.lateral_stiffness; params->start_lateral_damping = - FOLLOW_CAM_STATE(((struct UpdateCam *)camera_globals->unk180))->follow.lateral_damping; + FOLLOW_CAM_STATE(((struct UpdateCam *)camera_globals->current_camera)) + ->follow.lateral_damping; } /* One word over type and timer: type 5 on its first frame snaps the camera. */ if (*(s32 *)¶ms->type == SWING_CAMERA_TYPE_SNAP_ON_ENTRY) { @@ -390,7 +391,7 @@ s32 volume_camera_swing_check(struct UpdateCam *swing_camera_record) { params->timer == 0) { struct Hero *hero_data = &hero; if (hero_data->frames_off_ground.s != 0) { - if (current_level_index != 14) + if (current_level_index != LEVEL_OLTANIS) return 0; if (hero_data->unk2284 != 13) return 0; diff --git a/src/overlays/shared/camera/target_tracking_camera.c b/src/overlays/shared/camera/target_tracking_camera.c index 6c55570f89..5aac1dcb80 100644 --- a/src/overlays/shared/camera/target_tracking_camera.c +++ b/src/overlays/shared/camera/target_tracking_camera.c @@ -169,21 +169,24 @@ void update_target_tracking_camera_position(char *camera_object) { target = 4.64f; rate = 2.0f; } - FUN_L00_0025b868( - target, frame_time * 8.0f, (float *)(*(char **)((char *)l00_camera.unk180 + 0x70) + 0xa0)); - FUN_L00_0025b868( - rate, frame_time * 4.0f, (float *)(*(char **)((char *)l00_camera.unk180 + 0x70) + 0xb0)); - if (current_level_index == 14 && hero.state.current == 0x2c) + FUN_L00_0025b868(target, + frame_time * 8.0f, + (float *)(*(char **)((char *)l00_camera.current_camera + 0x70) + 0xa0)); + FUN_L00_0025b868(rate, + frame_time * 4.0f, + (float *)(*(char **)((char *)l00_camera.current_camera + 0x70) + 0xb0)); + if (current_level_index == LEVEL_OLTANIS && hero.state.current == 0x2c) FUN_L00_0025b868(rate + 0.25f, frame_time * 8.0f, - (float *)(*(char **)((char *)l00_camera.unk180 + 0x70) + 0x8c)); + (float *)(*(char **)((char *)l00_camera.current_camera + 0x70) + 0x8c)); else FUN_L00_0025b868(rate - 0.5f, frame_time * 8.0f, - (float *)(*(char **)((char *)l00_camera.unk180 + 0x70) + 0x8c)); + (float *)(*(char **)((char *)l00_camera.current_camera + 0x70) + 0x8c)); if (hero.state.current == 0x2c) { - if ((current_level_index != 14 && current_level_index != 7 && current_level_index != 9) || + if ((current_level_index != LEVEL_OLTANIS && current_level_index != LEVEL_UMBRIS && + current_level_index != LEVEL_GASPAR) || (hero.swing_target_moby != 0 && *(unsigned char *)((char *)hero.swing_target_moby + 0x21) == 255)) { *angle = @@ -336,7 +339,7 @@ void update_target_tracking_camera(char *camera_object) { } if (x != y) { LevelCamera *g = &l00_camera; - char *r = g->unk184; + char *r = g->previous_camera; qcopy(r + 0x30, camera_position); qcopy(r, camera_object); qcopy(r + 0x10, camera_object + 0x10); diff --git a/src/overlays/shared/cutscenes/the_plumber.c b/src/overlays/shared/cutscenes/the_plumber.c index 1d3175b451..74791ec835 100644 --- a/src/overlays/shared/cutscenes/the_plumber.c +++ b/src/overlays/shared/cutscenes/the_plumber.c @@ -178,14 +178,14 @@ void the_plumber_update(L01WatchMoby *plumber_moby) { case PLUMBER_INITIALIZE: plumber_moby->opacity = 0xFF; plumber_vars->i44 = 0; - if (current_level_index == 1) { + if (current_level_index == LEVEL_NOVALIS) { if (D_0013DD42) { mark_moby_for_removal(plumber_moby); return; } plumber_vars->dialogue_data = (void *)plumber_level_one_dialogue_data; plumber_moby->state = PLUMBER_LEVEL_ONE_DIALOGUE; - } else if (current_level_index == 8) { + } else if (current_level_index == LEVEL_BATALIA) { plumber_vars->dialogue_data = (void *)plumber_level_eight_dialogue_data; plumber_moby->state = PLUMBER_LEVEL_EIGHT_DIALOGUE; } else { diff --git a/src/overlays/shared/cutscenes/update_cutscene_playback.c b/src/overlays/shared/cutscenes/update_cutscene_playback.c index 568642c7c3..4510836653 100644 --- a/src/overlays/shared/cutscenes/update_cutscene_playback.c +++ b/src/overlays/shared/cutscenes/update_cutscene_playback.c @@ -608,15 +608,15 @@ int apply_cutscene_camera_key(void) { camera_key_rotation_matrix, camera_key_rotation_matrix, camera_key_values[1]); sceVu0RotMatrixZ(camera_key_rotation_matrix, camera_key_rotation_matrix, camera_key_values[2]); camera_state = &l00_camera_lui; - camera_state->unk350[0] = -camera_key_rotation_matrix[8]; - camera_state->unk350[4] = -camera_key_rotation_matrix[0]; - camera_state->unk350[8] = camera_key_rotation_matrix[4]; - camera_state->unk350[1] = -camera_key_rotation_matrix[9]; - camera_state->unk350[5] = -camera_key_rotation_matrix[1]; - camera_state->unk350[9] = camera_key_rotation_matrix[5]; - camera_state->unk350[2] = -camera_key_rotation_matrix[10]; - camera_state->unk350[6] = -camera_key_rotation_matrix[2]; - camera_state->unk350[10] = camera_key_rotation_matrix[6]; + camera_state->rows[0] = -camera_key_rotation_matrix[8]; + camera_state->rows[4] = -camera_key_rotation_matrix[0]; + camera_state->rows[8] = camera_key_rotation_matrix[4]; + camera_state->rows[1] = -camera_key_rotation_matrix[9]; + camera_state->rows[5] = -camera_key_rotation_matrix[1]; + camera_state->rows[9] = camera_key_rotation_matrix[5]; + camera_state->rows[2] = -camera_key_rotation_matrix[10]; + camera_state->rows[6] = -camera_key_rotation_matrix[2]; + camera_state->rows[10] = camera_key_rotation_matrix[6]; if (D_0015EDB4_298de8) fast_vec_cross(camera_position + 0x220, camera_position + 0x230, camera_position + 0x210); k = D_L00_0015F5A0; diff --git a/src/overlays/shared/enemies/blarg_elite_commando.c b/src/overlays/shared/enemies/blarg_elite_commando.c index 137b9d86e5..01d022dba3 100644 --- a/src/overlays/shared/enemies/blarg_elite_commando.c +++ b/src/overlays/shared/enemies/blarg_elite_commando.c @@ -502,7 +502,8 @@ void blarg_elite_commando_update(char *commando_moby) { update_blarg_elite_commando_joint_aim(commando_moby); if (blarg_elite_commando_joint_sparks_enabled_gp && D_001413DC != 22) emit_blarg_elite_commando_joint_sparks(commando_moby); - if (current_level_index == 18 && D_L16_0015F5C4 == 2 && (unsigned int)(D_L16_0016CC90 - 3) < 3U) + if (current_level_index == LEVEL_VELDIN2 && D_L16_0015F5C4 == 2 && + (unsigned int)(D_L16_0016CC90 - 3) < 3U) mark_moby_for_removal(commando_moby); } @@ -597,7 +598,7 @@ void update_blarg_elite_commando_damage_and_pursuit(struct Moby *commando_moby) case HIT_RESPONSE_FATAL: case HIT_RESPONSE_FATAL_FALL: { char *source; - if (current_level_index == 18 && commando_data->reward_hits) { + if (current_level_index == LEVEL_VELDIN2 && commando_data->reward_hits) { ++*(int *)&blarg_elite_commando_reward_kill_count_gp; if (*(int *)&blarg_elite_commando_reward_kill_count_gp >= 10) { if (item_unlocked[0x1D] == 0) { diff --git a/src/overlays/shared/enemies/blarg_ship_rocket.c b/src/overlays/shared/enemies/blarg_ship_rocket.c index 2b3572841c..665320580c 100644 --- a/src/overlays/shared/enemies/blarg_ship_rocket.c +++ b/src/overlays/shared/enemies/blarg_ship_rocket.c @@ -287,7 +287,7 @@ void blarg_ship_rocket_update(char *rocket) { rocket[0x20] = 2; break; case ROCKET_STATE_BURST: - if (current_level_index != 10) + if (current_level_index != LEVEL_ORXON) cart_burst(rocket, rocket + 0x10, -1, 0.25f, 13.0f); else cart_burst(rocket, rocket + 0x10, -1, 0.25f, 0.0f); diff --git a/src/overlays/shared/enemies/blarg_trooper_projectile.c b/src/overlays/shared/enemies/blarg_trooper_projectile.c index 7d460fde7f..c4eecbde68 100644 --- a/src/overlays/shared/enemies/blarg_trooper_projectile.c +++ b/src/overlays/shared/enemies/blarg_trooper_projectile.c @@ -203,7 +203,7 @@ void blarg_trooper_projectile_update(struct Moby *moby) { range = 64.0f; if (v->owner->oclass == 0xFF) range = 128.0f; - if (current_level_index == 12) + if (current_level_index == LEVEL_HOVEN) range = 100.0f; hero_distance = fast_vec_dist(&moby->pos, &hero.motion.pos); qcopy(&previous_position, &moby->pos); diff --git a/src/overlays/shared/enemies/bolt_thief_mine.c b/src/overlays/shared/enemies/bolt_thief_mine.c index a070f9d659..26b1392ed4 100644 --- a/src/overlays/shared/enemies/bolt_thief_mine.c +++ b/src/overlays/shared/enemies/bolt_thief_mine.c @@ -100,7 +100,7 @@ void bolt_thief_mine_update(struct Moby *moby) { } break; case FLOAT_MINE_ACTIVE: { - if (current_level_index == 16) { + if (current_level_index == LEVEL_KALEBO3) { if (floating_mine_private_vars->rest_z < 0.0f) floating_mine_private_vars->rest_z = probe_ground_height(0.5f, &moby->pos, 0) + 0.7f; @@ -110,7 +110,8 @@ void bolt_thief_mine_update(struct Moby *moby) { frame_scale_sq * 0.03f, frame_scale_sq * 0.3f, 0.0f); - if ((char *)moby > floating_mine_respawn_address_limit && hero.state.control_mode != 15) + if ((char *)moby > floating_mine_respawn_address_limit && + hero.state.control_mode != HERO_MODE_GRIND) goto remove; } hit = find_moby_hit(moby, 0x230000, 0); diff --git a/src/overlays/shared/enemies/gadgebot.c b/src/overlays/shared/enemies/gadgebot.c index 1f660633d3..659e54ffde 100644 --- a/src/overlays/shared/enemies/gadgebot.c +++ b/src/overlays/shared/enemies/gadgebot.c @@ -518,7 +518,7 @@ void gadgebot_update(GbMoby *moby) { int j; qcopy(vector_and_hit_scratch, moby->pos); - if (current_level_index != 6) { + if (current_level_index != LEVEL_NEBULA_G34) { gadgebot_vars->selected_path_slot = -1; if (gadgebot_vars->configured_path_count >= 2) { int i; @@ -707,7 +707,7 @@ void gadgebot_update(GbMoby *moby) { frame_time * 3.4906585f); break; case GADGEBOT_SEEK_AND_ATTACK_TARGET: - if (current_level_index != 6) { + if (current_level_index != LEVEL_NEBULA_G34) { int i; gadgebot_vars->selected_path_slot = -1; diff --git a/src/overlays/shared/game/init_level_runtime_state.c b/src/overlays/shared/game/init_level_runtime_state.c index 0cb40cf567..9265a12ca7 100644 --- a/src/overlays/shared/game/init_level_runtime_state.c +++ b/src/overlays/shared/game/init_level_runtime_state.c @@ -53,7 +53,7 @@ void init_level_runtime_state(void) { register_part_types(); dmac_vif1_enable(); init_level_item_inventory(); - if (current_level_index != 0) { + if (current_level_index != LEVEL_VELDIN1) { unlock_planet(current_level_index); } D_0015EE24 += 0xB4; diff --git a/src/overlays/shared/game/initialize_level_transition_with_audio.c b/src/overlays/shared/game/initialize_level_transition_with_audio.c index 8c49dd75b1..4ac2834768 100644 --- a/src/overlays/shared/game/initialize_level_transition_with_audio.c +++ b/src/overlays/shared/game/initialize_level_transition_with_audio.c @@ -36,7 +36,7 @@ void initialize_moby_state_record(char *moby) { int *moby_state_copy_source; D_L00_00160540_gp = 1; deactivate_recorded_moby(); - if (current_level_index == 0xD) { + if (current_level_index == LEVEL_OLTANIS_ORBIT) { char *global_record = D_0013E030_c; *(float *)(global_record + 0x60) = 464.66f; *(float *)(global_record + 0x64) = 580.68f; @@ -152,10 +152,11 @@ void initialize_level_transition_with_audio(int audio_selection_mode) { base_audio_selection_index = D_0013E030_28e9c8.x26; audio_stream_table_index = base_audio_selection_index + 1; secondary_track_index = base_audio_selection_index + 6; - if (current_level_index == 10 && base_audio_selection_index == 1 && D_0013D4C6_lui == 0) { + if (current_level_index == LEVEL_ORXON && base_audio_selection_index == 1 && + D_0013D4C6_lui == 0) { audio_stream_table_index = 0; secondary_track_index = 11; - } else if (current_level_index == 14 && D_0013E030_28e9c8.x26 == 2) { + } else if (current_level_index == LEVEL_OLTANIS && D_0013E030_28e9c8.x26 == 2) { audio_stream_table_index = 8; secondary_track_index = 14; } @@ -168,12 +169,13 @@ void initialize_level_transition_with_audio(int audio_selection_mode) { if (k) secondary_track_index = base_audio_selection_index; alternate_audio_stream_table_index = base_audio_selection_index + 5; - if (current_level_index == 10 && base_audio_selection_index == 1 && D_0013D4C6_lui == 0) { + if (current_level_index == LEVEL_ORXON && base_audio_selection_index == 1 && + D_0013D4C6_lui == 0) { secondary_track_index = 10; if (k) secondary_track_index = 9; alternate_audio_stream_table_index = 4; - } else if (current_level_index == 14 && D_0013E030_28e9c8.x26 == 2) { + } else if (current_level_index == LEVEL_OLTANIS && D_0013E030_28e9c8.x26 == 2) { secondary_track_index = 13; if (D_0013E030_28e9c8.x2c) secondary_track_index = 12; diff --git a/src/overlays/shared/game/run_level_main_loop.c b/src/overlays/shared/game/run_level_main_loop.c index 0eac06c95f..e9d4060dfc 100644 --- a/src/overlays/shared/game/run_level_main_loop.c +++ b/src/overlays/shared/game/run_level_main_loop.c @@ -141,7 +141,7 @@ void run_level_main_loop(void) { put_disp_buffer(); music_start_track(music_stream_state.primary.track, 1, 0x400); if ((current_level_index == one && level_available[3] == 0) || - (current_level_index == 0 && D_0013D390 != 0)) { + (current_level_index == LEVEL_VELDIN1 && D_0013D390 != 0)) { music_unpause(); } else { music_pause(0); diff --git a/src/overlays/shared/hero/adjust_hero_pose_targets_from_motion.c b/src/overlays/shared/hero/adjust_hero_pose_targets_from_motion.c index a6f452e5c3..3a13662268 100644 --- a/src/overlays/shared/hero/adjust_hero_pose_targets_from_motion.c +++ b/src/overlays/shared/hero/adjust_hero_pose_targets_from_motion.c @@ -131,7 +131,8 @@ void adjust_hero_pose_targets_from_motion(void) { hero_eases[14].rot_target.f[2] = -scaled_pose_input * 0.3f; hero_eases[15].rot_target.f[2] = -scaled_pose_input * 0.3f; hero_eases[16].rot_target.f[2] = -scaled_pose_input * 0.3f; - } else if (hero.state.control_mode == 2 || hero.state.control_mode == 4) { + } else if (hero.state.control_mode == HERO_MODE_FALL || + hero.state.control_mode == HERO_MODE_JUMP) { set_first_hero_easing_parameters(0.04f, 0.2f); set_second_hero_easing_parameters(0.04f, 0.2f); set_third_hero_easing_parameters(0.04f, 0.2f); diff --git a/src/overlays/shared/hero/handle_hero_hit.c b/src/overlays/shared/hero/handle_hero_hit.c index 298ed0b8d7..3605db62c2 100644 --- a/src/overlays/shared/hero/handle_hero_hit.c +++ b/src/overlays/shared/hero/handle_hero_hit.c @@ -33,10 +33,10 @@ s32 handle_hero_hit(s32 apply_response) { f32 xy_response_scale, z_response_amount, frame_time_scale; OvlVec4 response_vector; - if (G.state.control_mode == 0x14) { + if (G.state.control_mode == HERO_MODE_DYING) { return 0; } - if (G.state.control_mode == 7) { + if (G.state.control_mode == HERO_MODE_HURT) { return 0; } if (G.state.current == 0x32) { @@ -63,7 +63,7 @@ s32 handle_hero_hit(s32 apply_response) { D_0013DF88[current_level_index]++; G.damage_source_moby = (struct Moby *)hero_moby_entry->target; D_0015EEA8++; - if (G.state.control_mode == 0xF) { + if (G.state.control_mode == HERO_MODE_GRIND) { G.unk5BE = 1; return 0; } @@ -98,20 +98,20 @@ s32 handle_hero_hit(s32 apply_response) { G.motion.resolved_velocity_z.f[2] = frame_time * 7.0f; return 1; } - if (G.state.control_mode == 0x12) { + if (G.state.control_mode == HERO_MODE_WATER_SURFACE) { mob = (u8 *)G.damage_source_moby; if (mob != 0 && *(s16 *)(mob + 0xA6) == 0x28F) { id = 0x82; goto call_ret; } hero_set_state(0x75, 1); - } else if (G.state.control_mode == 0x11) { + } else if (G.state.control_mode == HERO_MODE_SWIM) { mob = (u8 *)G.damage_source_moby; if (mob != 0 && *(s16 *)(mob + 0xA6) == 0x28F) { id = 0x82; goto call_ret; } - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || current_level_index == LEVEL_VELDIN_ORBIT) { mob = (u8 *)G.damage_source_moby; if (mob != 0 && (*(s16 *)(mob + 0xA6) == 0x28F || *(s16 *)(mob + 0xA6) == 0x7B || *(s16 *)(mob + 0xA6) == 0x29D)) { @@ -119,7 +119,7 @@ s32 handle_hero_hit(s32 apply_response) { } } hero_set_state(0x76, 1); - } else if (G.state.control_mode == 3) { + } else if (G.state.control_mode == HERO_MODE_LEDGE) { mob = (u8 *)G.damage_source_moby; if (mob != 0) { id = 0x82; diff --git a/src/overlays/shared/hero/hero_frame_update.c b/src/overlays/shared/hero/hero_frame_update.c index 5d0f58a080..4645e75d61 100644 --- a/src/overlays/shared/hero/hero_frame_update.c +++ b/src/overlays/shared/hero/hero_frame_update.c @@ -315,7 +315,7 @@ void update_hero_blink_and_gold_weapon_tint(void) { blink = 0; if (hero.state.current == 0x80 || hero.state.current == 0x82) blink = hero.state_timer < scale_game_frames(30); - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || current_level_index == LEVEL_VELDIN_ORBIT) { if (hero.state.current == 0x76 && hero.state_timer < scale_game_frames(20)) blink = 1; } @@ -381,7 +381,7 @@ void update_hero_ground_material_effects(void) { q = &hero; q->base_condition = 1; } - if (current_level_index == 0xD) { + if (current_level_index == LEVEL_OLTANIS_ORBIT) { struct Hero *q = &hero; if (q->state.current != 0x7B) { if (func_L00_001F10E0_2cd48(q->capsule_radius + 0.03f, &q->motion.body_center, 2, 0)) { @@ -468,10 +468,10 @@ void update_hero_ledge_probe(void) { return; allowed = 0; if (hero.vehicle_mode == HERO_VEHICLE_MODE_ON_FOOT) { - if ((hero.state.control_mode == 4 && + if ((hero.state.control_mode == HERO_MODE_JUMP && (hero.past_jump_apex != 0 || hero.motion.velocity.f[2] < frame_time * 3.5f)) || - hero.state.control_mode == 2 || hero.state.current == 8 || hero.state.current == 0x1A || - hero.state.current == 0x1B) + hero.state.control_mode == HERO_MODE_FALL || hero.state.current == 8 || + hero.state.current == 0x1A || hero.state.current == 0x1B) allowed = 1; if (hero.state.current == 0xE && hero.anim_frame < 37.0f) allowed = 0; @@ -486,7 +486,7 @@ void update_hero_ledge_probe(void) { reach = 1.15f; edge_offset = 0.45f; launch_scale = hero.fall_state_gravity; - if (hero.state.control_mode == 4) + if (hero.state.control_mode == HERO_MODE_JUMP) launch_scale = hero.jump_gravity; frames = scale_game_frames(2); step = 0.25f; @@ -838,10 +838,10 @@ s32 process_hero_hit_response(s32 apply_state_and_motion_response) { f32 horizontal_scale, vertical_amount, cached_frame_time; OvlVec4 motion_delta; - if (G.state.control_mode == 0x14) { + if (G.state.control_mode == HERO_MODE_DYING) { return 0; } - if (G.state.control_mode == 7) { + if (G.state.control_mode == HERO_MODE_HURT) { return 0; } if (G.state.current == 0x32) { @@ -899,20 +899,20 @@ s32 process_hero_hit_response(s32 apply_state_and_motion_response) { G.motion.resolved_velocity_z.f[2] = frame_time * 7.0f; return 1; } - if (G.state.control_mode == 0x12) { + if (G.state.control_mode == HERO_MODE_WATER_SURFACE) { mob = (u8 *)G.damage_source_moby; if (mob != 0 && *(s16 *)(mob + 0xA6) == 0x28F) { id = 0x82; goto call_ret; } l01_hero_set_state(0x75, 1); - } else if (G.state.control_mode == 0x11) { + } else if (G.state.control_mode == HERO_MODE_SWIM) { mob = (u8 *)G.damage_source_moby; if (mob != 0 && *(s16 *)(mob + 0xA6) == 0x28F) { id = 0x82; goto call_ret; } - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || current_level_index == LEVEL_VELDIN_ORBIT) { mob = (u8 *)G.damage_source_moby; if (mob != 0 && (*(s16 *)(mob + 0xA6) == 0x28F || *(s16 *)(mob + 0xA6) == 0x7B || *(s16 *)(mob + 0xA6) == 0x29D)) { @@ -920,7 +920,7 @@ s32 process_hero_hit_response(s32 apply_state_and_motion_response) { } } l01_hero_set_state(0x76, 1); - } else if (G.state.control_mode == 3) { + } else if (G.state.control_mode == HERO_MODE_LEDGE) { mob = (u8 *)G.damage_source_moby; if (mob != 0) { id = 0x82; @@ -973,7 +973,7 @@ void update_hero_collision_dimensions(void) { hero.capsule_radius_target = 0.45f; break; } - if (hero.state.control_mode == 4) { + if (hero.state.control_mode == HERO_MODE_JUMP) { if (hero.state_timer > hero.takeoff_frame && hero.past_jump_apex == 0) hero.capsule_bottom_target = hero.unk434; } else if (hero.state.current == HERO_STATE_FALL) { @@ -986,8 +986,8 @@ void update_hero_collision_dimensions(void) { } else if (hero.state.current == HERO_STATE_SINK) { hero.capsule_radius_target = 0.8f; } - if (!hero.wall_hit || hero.state.prev_control_mode == 0x12 || hero.state.control_mode == 0x11 || - hero.base_condition || + if (!hero.wall_hit || hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE || + hero.state.control_mode == HERO_MODE_SWIM || hero.base_condition || vector_distance_xy(hero.wall_contact_point.f, hero.motion.pos.f) > hero.capsule_radius * 0.5f) { f32 *smoothed_values = D_0013F570; @@ -1180,7 +1180,7 @@ void update_hero_ground_contact_and_gravity(void) { if (hero.gravity_mode) k = 1; ground_ray_start_offset = hero.capsule_radius * 2.2f; - if (hero.state.control_mode == 2) { + if (hero.state.control_mode == HERO_MODE_FALL) { ground_ray_start_offset = hero.capsule_radius * 2.9f; } hero_get_collision_ray_endpoints( @@ -1204,7 +1204,7 @@ void update_hero_ground_contact_and_gravity(void) { goto d1; } collision_sound_class = coll_sound_class(); - if (current_level_index == 1 || current_level_index == 0x12) { + if (current_level_index == LEVEL_NOVALIS || current_level_index == LEVEL_VELDIN2) { collision_sound_class = 3; } hero.ground_sound_class = collision_sound_class; @@ -1285,9 +1285,9 @@ void update_hero_ground_contact_and_gravity(void) { hero.unk2C8.i[1] = 0; hero.unk2C0.i[0] = 0; hero.unk2C0.i[1] = 0; - if (hero.state.control_mode == 0xF || hero.state.control_mode == 0x15 || - hero.state.control_mode == 6 || hero.state.control_mode == 4 || - hero.state.control_mode == 5 || hero.state.control_mode == 3) { + if (hero.state.control_mode == HERO_MODE_GRIND || hero.state.control_mode == 0x15 || + hero.state.control_mode == HERO_MODE_ATTACK || hero.state.control_mode == HERO_MODE_JUMP || + hero.state.control_mode == HERO_MODE_LAND || hero.state.control_mode == HERO_MODE_LEDGE) { return; } if (!(hero.ground_distance < 0.25f)) { @@ -1362,7 +1362,7 @@ s32 resolve_hero_position_with_collision_queries(s32 mode) { resolve_hero_pending_path_clearance(); hero.path_constrain_pending = 0; } - if (hero.state.control_mode != 0x11) { + if (hero.state.control_mode != HERO_MODE_SWIM) { if (hero.gravity_mode != HERO_GRAVITY_WORLD_DOWN || hero.unk1F8 != 0) { if (hero.gravity_mode == HERO_GRAVITY_OPPOSITE_GROUND_NORMAL || hero.unk1F8 != 0) { add_hero_up_offset(&collision_query_offset, &collision_query_offset, 0.6f); @@ -1383,7 +1383,7 @@ s32 resolve_hero_position_with_collision_queries(s32 mode) { if (hero.gravity_mode != HERO_GRAVITY_WORLD_DOWN) { if (!coll_sphere(&hero.motion.pos.q, mask, ((s32)hero.moby), frame_scale * 0.4f)) break; - } else if (hero.state.control_mode == 0x11) { + } else if (hero.state.control_mode == HERO_MODE_SWIM) { if (!coll_sphere(&hero.motion.pos.q, mask, ((s32)hero.moby), 0.6f)) break; } else { diff --git a/src/overlays/shared/hero/hero_handle_jump_press.c b/src/overlays/shared/hero/hero_handle_jump_press.c index 68c809210e..f53de599e8 100644 --- a/src/overlays/shared/hero/hero_handle_jump_press.c +++ b/src/overlays/shared/hero/hero_handle_jump_press.c @@ -61,7 +61,7 @@ s32 pick_idle_fidget(s32 *index) { if (fidget_candidate->use_state_40 != 0 && hero.ground_moby != 0) continue; if (i == 3) { - if (current_level_index != 12) + if (current_level_index != LEVEL_HOVEN) continue; if (hero_slot_item_id(0) == 23) continue; @@ -73,7 +73,7 @@ s32 pick_idle_fidget(s32 *index) { continue; } if (i == 4) { - if (hero.state.prev_control_mode != 1) + if (hero.state.prev_control_mode != HERO_MODE_RUN) continue; if (scale_game_frames(50) < hero.state_timer) continue; diff --git a/src/overlays/shared/hero/hero_idle_sequence.c b/src/overlays/shared/hero/hero_idle_sequence.c index e8902e8a03..5ba41d78f3 100644 --- a/src/overlays/shared/hero/hero_idle_sequence.c +++ b/src/overlays/shared/hero/hero_idle_sequence.c @@ -613,7 +613,7 @@ void emit_hero_animation_voice_and_ground_particle(int record_group_index, request_grouped_voice( record_group_index, joint_index_offset, item_moby_is_type_ad, 0, ((int)g->moby)); } - if (current_level_index == 12) { + if (current_level_index == LEVEL_HOVEN) { struct Hero *g = &hero; if (g->ground_sound_class == 0 && ((int)g->ground_moby) == 0) { float k = 0.15f; @@ -1117,7 +1117,7 @@ void scan_hero_input_sequences(void) { g = &hero; input_token = 0; if (g->state_timer == scale_game_frames(0xF)) { - if (g->state.control_mode == 4) { + if (g->state.control_mode == HERO_MODE_JUMP) { int b = g->state.current; if (b == 0xB) { int token_variant_selector = g->unk450; @@ -1139,7 +1139,7 @@ void scan_hero_input_sequences(void) { } else if (b == 0xE) { input_token = 5; } - } else if (g->state.control_mode == 6) { + } else if (g->state.control_mode == HERO_MODE_ATTACK) { int b = g->state.current; if (b == 0x14) { input_token = 6; @@ -1437,8 +1437,8 @@ void update_hero_color_and_item_tint(void) { if (hero.state.current == 0x80 || hero.state.current == 0x82) { blink = hero.state_timer < scale_game_frames(0x1e); } - if ((current_level_index == 0xf || current_level_index == 0x11) && hero.state.current == 0x76 && - hero.state_timer < scale_game_frames(0x14)) { + if ((current_level_index == LEVEL_QUARTU || current_level_index == LEVEL_VELDIN_ORBIT) && + hero.state.current == 0x76 && hero.state_timer < scale_game_frames(0x14)) { blink = 1; } if (blink) { @@ -1960,7 +1960,7 @@ void update_hero_moby(void) { set_moby_local_table_entry( ((unsigned char *)hero.moby), 0, position_scratch, hero.capsule_radius, top_gap); second_position_offset = hero.capsule_radius + minimum_top_gap; - if (hero.state.control_mode == 4) + if (hero.state.control_mode == HERO_MODE_JUMP) second_position_offset += 0.15f; if (hero_is_in_special_state()) second_position_offset = hero.capsule_bottom; @@ -3364,8 +3364,8 @@ void probe_hero_airborne_wall_contact(void) { f = fast_arc_tan(collision_result->x, collision_result->y); } k2->unk460.f[3] = f; - if (k2->state.control_mode != 4 && k2->state.prev_control_mode != 4 && - k2->state.prev2_control_mode != 4) { + if (k2->state.control_mode != HERO_MODE_JUMP && k2->state.prev_control_mode != HERO_MODE_JUMP && + k2->state.prev2_control_mode != HERO_MODE_JUMP) { return; } hero_state = &hero; @@ -3485,7 +3485,7 @@ void apply_hero_selected_flags_and_state_transitions(void) { } if (saved_flag_selector == 3) P.jump_or_respawn_wait_transition_selected = 1; - if (current_level_index == 13 && P.i2084 != 0x7B && + if (current_level_index == LEVEL_OLTANIS_ORBIT && P.i2084 != 0x7B && coll_sphere((u8 *)&P + 0xD0, 2, 0, P.f234 + 0.03f) && FUN_001f0b58_20b960() == 11) { goto s7B; } @@ -3604,10 +3604,10 @@ void check_ledge_grab(void) { return; can_grab = 0; if (((Hero *)D_0013F450_20C568)->vehicle_mode == 0) { - if ((((Hero *)D_0013F450_20C568)->state.control_mode == 4 && + if ((((Hero *)D_0013F450_20C568)->state.control_mode == HERO_MODE_JUMP && (((Hero *)D_0013F450_20C568)->past_jump_apex != 0 || ((Hero *)D_0013F450_20C568)->motion.velocity.f[2] < D_0015ED6C * 3.5f)) || - ((Hero *)D_0013F450_20C568)->state.control_mode == 2 || + ((Hero *)D_0013F450_20C568)->state.control_mode == HERO_MODE_FALL || ((Hero *)D_0013F450_20C568)->state.current == 8 || ((Hero *)D_0013F450_20C568)->state.current == 0x1A || ((Hero *)D_0013F450_20C568)->state.current == 0x1B) @@ -3617,10 +3617,10 @@ void check_ledge_grab(void) { can_grab = 0; } if (((Hero *)D_0013F450_20C568)->vehicle_mode == 1) { - if ((((Hero *)D_0013F450_20C568)->state.control_mode == 4 && + if ((((Hero *)D_0013F450_20C568)->state.control_mode == HERO_MODE_JUMP && (((Hero *)D_0013F450_20C568)->past_jump_apex != 0 || ((Hero *)D_0013F450_20C568)->motion.velocity.f[2] < D_0015ED6C * 2.5f)) || - ((Hero *)D_0013F450_20C568)->state.control_mode == 2 || + ((Hero *)D_0013F450_20C568)->state.control_mode == HERO_MODE_FALL || ((Hero *)D_0013F450_20C568)->state.current == 0x4F || ((Hero *)D_0013F450_20C568)->state.current == 0x4D || ((Hero *)D_0013F450_20C568)->state.current == 0x4E) @@ -3646,7 +3646,7 @@ void check_ledge_grab(void) { back = 0.32f; } speed = ((Hero *)D_0013F450_20C568)->fall_state_gravity; - if (((Hero *)D_0013F450_20C568)->state.control_mode == 4) + if (((Hero *)D_0013F450_20C568)->state.control_mode == HERO_MODE_JUMP) speed = ((Hero *)D_0013F450_20C568)->jump_gravity; frames = scale_game_frames(2); predict_position_with_vertical_drop(probe, diff --git a/src/overlays/shared/hero/hero_move_state_velocity.c b/src/overlays/shared/hero/hero_move_state_velocity.c index 8023f15877..a148774570 100644 --- a/src/overlays/shared/hero/hero_move_state_velocity.c +++ b/src/overlays/shared/hero/hero_move_state_velocity.c @@ -172,7 +172,7 @@ void hero_move_state_velocity(void) { qcopy(&hero.motion.momentum, &hero.move_impulse); base_planar_velocity_step = ED70 * 20.0f; if (hero.target_speed < hero_deceleration_speed_reference[0] * ED6C * 0.2f) { - if (hero.state.control_mode == 2) { + if (hero.state.control_mode == HERO_MODE_FALL) { planar_speed_reduction_step = hero.stickless_decel; if (hero.on_ice_ground) planar_speed_reduction_step = ED70 * 0.17f; @@ -1193,7 +1193,7 @@ void spawn_hero_radial_particle_burst(void) { b = truncate_float_to_s32(random_float_between(21000.0f, 31500.002f) / 1000.0f); vector_magnitude = random_float_between(frame_time * 0.15f, frame_time * 0.7f); qcopy(randomized_position, position_source); - if (current_level_index != 6) { + if (current_level_index != LEVEL_NEBULA_G34) { randomized_position[0].f[2] = *(float *)(g + 0x2F4); } i--; diff --git a/src/overlays/shared/hero/hero_set_state.c b/src/overlays/shared/hero/hero_set_state.c index 581b3e1e7b..6d04ac1ec7 100644 --- a/src/overlays/shared/hero/hero_set_state.c +++ b/src/overlays/shared/hero/hero_set_state.c @@ -686,7 +686,7 @@ int hero_set_state(int requested_state, int b) { V4_222B80 sampled_path_position; { struct Hero *p = &hero; - if (p->state.control_mode == 0x14 && + if (p->state.control_mode == HERO_MODE_DYING && (requested_state != HERO_STATE_IDLE_ANIMATION_WITH_DYING_OVERRIDE || b != 2)) return 0; } @@ -694,7 +694,8 @@ int hero_set_state(int requested_state, int b) { return 0; { struct Hero *p = &hero; - if (p->health.hp == 0 && (p->state.control_mode == 2 || p->state.control_mode == 7) && + if (p->health.hp == 0 && + (p->state.control_mode == HERO_MODE_FALL || p->state.control_mode == HERO_MODE_HURT) && requested_state != HERO_STATE_FALL && requested_state != HERO_STATE_DYING && requested_state != HERO_STATE_VEHICLE_MODE_1_DYING && requested_state != HERO_STATE_VEHICLE_MODE_3_DYING && @@ -745,7 +746,7 @@ int hero_set_state(int requested_state, int b) { switch (requested_state) { case HERO_STATE_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; p->unk1010 = random_int_between(scale_game_frames(0x32), scale_game_frames(0x64)); clear_hero_idle_rotation_targets(); @@ -780,7 +781,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_AT_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; clear_u64_value(&p->motion.momentum); p->rand_timer.range = 0x68; @@ -806,7 +807,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (b) @@ -815,7 +816,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_DYING_SPEED_LIMITED: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -826,7 +827,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_SINK: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->unk694 = p->motion.displacement.f[2] * 0.2f; @@ -842,11 +843,11 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_SWIM: { struct Hero *p = &hero; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; *(int *)&p->drown_sink_speed = 0; - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } else { @@ -866,11 +867,11 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_SWIM_WITH_CROUCH_INPUT: { struct Hero *p = &hero; int n; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; p->unk8F4 = scale_game_frames(0x3C); - if (p->state.prev_control_mode == 0x12) { + if (p->state.prev_control_mode == HERO_MODE_WATER_SURFACE) { allocate_hero_voice_for_entry(3, 0); p->state.step = 1; } @@ -886,7 +887,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_SWIM_IDLE: { struct Hero *p = &hero; int n; - p->state.control_mode = 0x11; + p->state.control_mode = HERO_MODE_SWIM; p->unk2284 = 0xB; p->item_select_blocked = 1; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -900,11 +901,11 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_WATER_SURFACE_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; p->splash_effect_timer = 0; - if (p->state.prev_control_mode == 0x11) { + if (p->state.prev_control_mode == HERO_MODE_SWIM) { emit_hero_surface_effect_burst(3, 0xA, 0); if (D_L00_001612D0 != 0) { pool_splash(D_L00_001612D0, @@ -932,7 +933,7 @@ int hero_set_state(int requested_state, int b) { { struct Hero *q = &hero; q->unk698 = 0; - if (q->state.prev_control_mode == 0x11) { + if (q->state.prev_control_mode == HERO_MODE_SWIM) { if ((float)q->underwater_air < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); } else if ((float)q->underwater_air < 7500.0f) { @@ -940,7 +941,7 @@ int hero_set_state(int requested_state, int b) { } { struct Hero *r = &hero; - if (r->state.prev_control_mode == 0x11) { + if (r->state.prev_control_mode == HERO_MODE_SWIM) { if ((float)r->underwater_air < 2500.0f) { help_queue_add(8, scale_game_frames(0x1E), 0); } else if ((float)r->underwater_air < 7500.0f) { @@ -971,7 +972,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->item_select_blocked = 1; @@ -1003,7 +1004,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_WATER_SURFACE_MOVE: { struct Hero *p = &hero; - p->state.control_mode = 0x12; + p->state.control_mode = HERO_MODE_WATER_SURFACE; p->item_select_blocked = 1; p->unk2284 = 0; *(int *)&p->drown_sink_speed = 0; @@ -1015,7 +1016,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_DROWN: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -1057,7 +1058,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_DYING_ZERO_HEALTH: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->item_select_blocked = 1; p->unk2284 = 0; p->health.hp = 0; @@ -1093,7 +1094,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_LOOK: { struct Hero *p = &hero; int t; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 4; *(int *)&D_L00_0015F688 = scale_game_frames(0x3C); if (p->unk20AA == 0) { @@ -1106,7 +1107,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ITEM_BUTTON_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(hero_idle_sequence(0), 0, (float)scale_game_frames(0xA)); @@ -1115,7 +1116,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_WAIT_FOR_ITEM_RELEASE_THEN_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.displacement); set_hero_animation(hero_idle_sequence(0), 0, (float)scale_game_frames(5)); @@ -1124,7 +1125,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ITEM_BUTTON_HOLD_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.displacement); p->state.step = 0; @@ -1138,9 +1139,10 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_DIRECTION_LIMITED_GROUND_MOVE: case HERO_STATE_SHALLOW_WATER_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; - if (p->state.prev_control_mode != 4 && p->state.prev2_control_mode != 4) { + if (p->state.prev_control_mode != HERO_MODE_JUMP && + p->state.prev2_control_mode != HERO_MODE_JUMP) { p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); } { @@ -1151,7 +1153,8 @@ int hero_set_state(int requested_state, int b) { stick_target(0, 1.0f); if (1.5707964f < fast_difference_between_rotations(q->motion.rot.f[2], q->motion.move_yaw)) { - if (q->state.prev_control_mode == 7 || q->state.prev == 3 || q->state.prev2 == 3) { + if (q->state.prev_control_mode == HERO_MODE_HURT || q->state.prev == 3 || + q->state.prev2 == 3) { struct Hero *r = &hero; r->ground_speed = 0.0f; } @@ -1195,7 +1198,7 @@ int hero_set_state(int requested_state, int b) { n = scale_game_frames(0x12); { struct Hero *u = &hero; - if (u->state.prev2_control_mode == 4 && + if (u->state.prev2_control_mode == HERO_MODE_JUMP && scale_game_frames(5) < u->rail_land_frames) n = scale_game_frames(0xD); } @@ -1211,7 +1214,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ANIMATION_FRAME_EXIT_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; if (b) { if (p->state.prev == 4) { @@ -1224,7 +1227,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_APPROACH_TARGET_POSE: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->item_use_locked = 1; @@ -1256,7 +1259,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_STOP: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (p->on_ice_ground != 0) { @@ -1288,7 +1291,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_BRAKE_AT_TARGET_POSITION: { struct Hero *p = &hero; char *v = &p->motion.resolved_velocity; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = gravity_length_xy((float *)v); qcopy(&p->motion.momentum, v); @@ -1303,7 +1306,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_CROUCH: { struct Hero *p = &hero; - p->state.control_mode = 0xC; + p->state.control_mode = HERO_MODE_CROUCH; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); if (frame_time * 7.0f < p->ground_speed) @@ -1332,7 +1335,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_GRAPPLE_TARGET_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; { char *h = ((char *)&item_usage); @@ -1356,7 +1359,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_APPROACH_TARGET_MOBY: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; *(int *)&p->grapple_pull_speed = 0; p->grapple_pull_ending = 0; @@ -1367,7 +1370,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_CONSTRAIN_TO_TARGET_RADIUS: { struct Hero *p = &hero; - p->state.control_mode = 0xD; + p->state.control_mode = HERO_MODE_GRAPPLE; p->unk2284 = 7; p->item_use_locked = 1; *(int *)&p->grapple_pull_speed = 0; @@ -1380,7 +1383,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_GRAPPLE_SWING_ENTRY: { struct Hero *p = &hero; char *d; - p->state.control_mode = 0xE; + p->state.control_mode = HERO_MODE_GRAPPLE_SWING; p->unk2284 = 7; { char *h = ((char *)&item_usage); @@ -1426,9 +1429,9 @@ int hero_set_state(int requested_state, int b) { *(float *)(((char *)q->swing_target_moby) + 0x14) - q->motion.pos.f[1]); q->unk9A4 = fast_vec_dist(&q->motion.pos, ((char *)q->swing_target_moby) + 0x10); q->swing_gravity = frame_time_sq * 27.0f; - if (q->state.prev_control_mode == 4) { + if (q->state.prev_control_mode == HERO_MODE_JUMP) { q->swing_gravity = q->jump_gravity; - } else if (q->state.prev_control_mode == 2) { + } else if (q->state.prev_control_mode == HERO_MODE_FALL) { q->swing_gravity = q->fall_state_gravity; } if (b) { @@ -1443,7 +1446,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ITEM_RELEASE_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 7; clear_u64_value(&p->motion.rot_spring_vel); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -1468,14 +1471,14 @@ int hero_set_state(int requested_state, int b) { int i; float f; float t; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 3; p->rand_timer.range = 0x68; p->grind_direction = 1; p->grind_yaw_offset = -1.5707964f; p->rail_off_frames = 0; p->grind_anim_variant = 0; - if (p->state.prev_control_mode != 0xF) { + if (p->state.prev_control_mode != HERO_MODE_GRIND) { p->unk5AC.i = 0; p->grind_pose = -1; p->grind_base_speed = 0.0f; @@ -1496,7 +1499,7 @@ int hero_set_state(int requested_state, int b) { fast_vec_sub(&d.v, &sampled_path_position, &p->motion.pos); if (0.001f < fast_vec_length(&d.v)) { fast_vec_normalize(&d.v, &d.v, 1.0f); - if (p->state.prev_control_mode != 0xF) { + if (p->state.prev_control_mode != HERO_MODE_GRIND) { p->grind_base_speed = fast_vec_dot(&p->motion.displacement, &d.v); } } @@ -1525,7 +1528,7 @@ int hero_set_state(int requested_state, int b) { int i; float f; float t; - p->state.control_mode = 0x1A; + p->state.control_mode = HERO_MODE_FOLLOW_PATH; p->unk2284 = 3; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -1553,11 +1556,11 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 24.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -1573,7 +1576,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; p->rand_timer.range = 0x68; @@ -1583,7 +1586,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_LEDGE_SHIMMY_POSITIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (b) @@ -1592,7 +1595,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_LEDGE_SHIMMY_NEGATIVE_YAW: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->item_select_blocked = 1; if (b) @@ -1601,7 +1604,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (b) @@ -1611,7 +1614,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_FALL: case HERO_STATE_FATAL_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -1650,7 +1653,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_DELAYED_JUMP_OR_R1_REPEAT_EXIT_WAIT: { struct Hero *p = &hero; int animation_timing_preset = -2; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk22CA = 1; p->rand_timer.range = 0x68; p->unk2284 = 0; @@ -1666,7 +1669,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_LAND: { struct Hero *p = &hero; int animation_timing_selector = -2; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->rand_timer.range = 0x68; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { @@ -1704,7 +1707,7 @@ int hero_set_state(int requested_state, int b) { p->state_timer = p->state.prev_timer; return 0; } - p->state.control_mode = 4; + p->state.control_mode = HERO_MODE_JUMP; if (requested_state >= HERO_STATE_GRIND_JUMP && requested_state <= HERO_STATE_GRIND_RAIL_TRANSFER) { p->unk2284 = 3; @@ -1807,11 +1810,11 @@ int hero_set_state(int requested_state, int b) { u->unk498 = scale_game_frames(2); u->jump_max_frames = scale_game_frames(0x78); hero_change_health(1); - if (current_level_index == 0xA) { + if (current_level_index == LEVEL_ORXON) { hero_set_state(0x7C, 1); return 0; } - if (current_level_index != 6) { + if (current_level_index != LEVEL_NEBULA_G34) { if (u->state.prev == 0x3C || u->state.prev2 == 0x3C || u->health.hp == 0) { struct Hero *w = &hero; w->sink_jump_count = w->sink_jump_count + 1; @@ -1832,7 +1835,7 @@ int hero_set_state(int requested_state, int b) { } } else if (u->state.current == 0x69) { float v; - u->state.control_mode = 0x19; + u->state.control_mode = HERO_MODE_RESPAWN_WAIT; if (u->motion.pos.f[2] < u->sink_surface_z) { v = u->sink_surface_z - u->motion.pos.f[2]; } else { @@ -1861,7 +1864,7 @@ int hero_set_state(int requested_state, int b) { u->jump_height_start = 2.4f; u->unk498 = scale_game_frames(0x11); u->jump_gravity = frame_time_sq * 27.0f; - u->state.control_mode = 0xF; + u->state.control_mode = HERO_MODE_GRIND; u->rail_gap_jump = 0; if (u->selector_5 != 0) { float h = 4.7f; @@ -1891,7 +1894,7 @@ int hero_set_state(int requested_state, int b) { u->jump_height_start = 2.5f; u->unk498 = scale_game_frames(0xA); u->jump_gravity = frame_time_sq * 24.0f; - u->state.control_mode = 0xF; + u->state.control_mode = HERO_MODE_GRIND; u->rail_gap_jump = 0; } else if (u->state.current == 9) { u->unk430 = 1.0f; @@ -2156,7 +2159,7 @@ int hero_set_state(int requested_state, int b) { } else if (s == 0xA) { set_hero_animation(0x12, 0, (float)scale_game_frames(5)); } else if (s == 0x10) { - if (q->state.prev_control_mode == 4 || + if (q->state.prev_control_mode == HERO_MODE_JUMP || (q->state.prev == 4 && scale_game_frames(7) > q->state_timer)) { set_hero_animation(0x26, 0, (float)scale_game_frames(8)); q->takeoff_frame += scale_game_frames(3); @@ -2190,7 +2193,7 @@ int hero_set_state(int requested_state, int b) { } { struct Hero *w = &hero; - if (w->state.prev_control_mode == 4) { + if (w->state.prev_control_mode == HERO_MODE_JUMP) { set_hero_animation(id, 1, (float)scale_game_frames(4)); w->takeoff_frame = scale_game_frames(1); } else { @@ -2209,7 +2212,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_ANIMATION_RECOVERY_WITH_JUMP_CANCEL: case HERO_STATE_VEHICLE_MODE_1_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->speed_scale = 1.0f; p->unk2284 = 0; p->heading_locked = 0; @@ -2313,7 +2316,8 @@ int hero_set_state(int requested_state, int b) { e = &attack_records[q->attack_record]; q->saved_item[0] = 0; k = 0; - if (q->state.prev_control_mode == 6 && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { + if (q->state.prev_control_mode == HERO_MODE_ATTACK && e->unk0 == 0 && + q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 3; } { @@ -2354,8 +2358,8 @@ int hero_set_state(int requested_state, int b) { struct Hero *q = &hero; HeroTableRow2C *e = &attack_records[q->attack_record]; int k = 0; - if ((q->state.prev_control_mode == 6 || - (q->state.prev2_control_mode == 6 && + if ((q->state.prev_control_mode == HERO_MODE_ATTACK || + (q->state.prev2_control_mode == HERO_MODE_ATTACK && (unsigned int)(q->moby->prev_seq - 0xF) < 2)) && e->unk0 == 0 && q->anim_frame < (float)e->unk8) { k = (e->kind + 1) % 2; @@ -2394,7 +2398,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ATTACK_RECORD_FRAME_EXIT_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unkA64 = 0; if (p->state.prev == 0x70) { int v = 5; @@ -2421,7 +2425,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_GRIND_ATTACK: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unkA64 = 0; if (p->state.prev == 0x2B) { p->attack_record = p->attack_record == 0; @@ -2472,7 +2476,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_HURT: { struct Hero *p = &hero; char *r; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); p->unk1EE = scale_game_frames(0x2D); @@ -2497,7 +2501,8 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_WAIT_FOR_JUMP_OR_RESPAWN: { struct Hero *p = &hero; if (p->state.prev == 0x69 || - (p->state.prev2 == 0x69 && p->state.prev_control_mode != 0 && p->state.prev != 7)) { + (p->state.prev2 == 0x69 && p->state.prev_control_mode != HERO_MODE_IDLE && + p->state.prev != 7)) { p->sink_jump_count = p->sink_jump_count + 1; } else { struct Hero *q = &hero; @@ -2505,7 +2510,7 @@ int hero_set_state(int requested_state, int b) { } { struct Hero *r = &hero; - r->state.control_mode = 0x19; + r->state.control_mode = HERO_MODE_RESPAWN_WAIT; r->unk2284 = 0; allocate_hero_voice_for_entry(9, 0); r->rand_timer.range = 0x68; @@ -2518,9 +2523,9 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_HEIGHT_OR_TIMEOUT_RESPAWN_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0x19; + p->state.control_mode = HERO_MODE_RESPAWN_WAIT; p->unk2284 = 0; - if (current_level_index == 0xF) + if (current_level_index == LEVEL_QUARTU) spawn_hero_radial_particle_burst(); p->collision_off_frames = 0x2710; allocate_hero_voice_for_entry(9, 0); @@ -2530,7 +2535,7 @@ int hero_set_state(int requested_state, int b) { break; } case HERO_STATE_DEATH_DESCENT: { - if (current_level_index == 6) { + if (current_level_index == LEVEL_NEBULA_G34) { int c0; int c1; int c2; @@ -2545,7 +2550,7 @@ int hero_set_state(int requested_state, int b) { } { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->collision_off_frames = 0x2710; @@ -2559,7 +2564,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_VEHICLE_MODE_1_DEATH_DESCENT: { struct Hero *p = &hero; char *m; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; p->collision_off_frames = 0x2710; @@ -2573,7 +2578,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_1_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (p->on_slip_ground != 0 && p->frames_off_ground.s == 0) { hero_set_state(0x52, 1); @@ -2585,7 +2590,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_1_LAND: { struct Hero *p = &hero; - p->state.control_mode = 5; + p->state.control_mode = HERO_MODE_LAND; p->unk2284 = 0; if (frame_time * 4.5f < p->motion.speed_xy) { scale_hero_motion(frame_time * 4.5f / p->motion.speed_xy); @@ -2597,7 +2602,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_1_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->stickless_decel = frame_time_sq * 7.0f; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -2607,7 +2612,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_1_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (b) @@ -2616,7 +2621,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_1_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -2638,12 +2643,12 @@ int hero_set_state(int requested_state, int b) { } { struct Hero *q = &hero; - q->state.control_mode = 1; + q->state.control_mode = HERO_MODE_RUN; q->unk2284 = 0; q->ground_speed = vector_length_xy(&q->motion.resolved_velocity); if (q->state.prev == 3) q->ground_speed = 0.0f; - if (q->state.prev_control_mode == 0) + if (q->state.prev_control_mode == HERO_MODE_IDLE) q->ground_speed = vector_length_xy(&q->motion.momentum); q->unk3B8 = 0; if (b) @@ -2653,7 +2658,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_1_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; p->health.hp = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); @@ -2663,11 +2668,11 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ALT_LEDGE_HANG_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; p->unk4EC = frame_time_sq * 12.0f; p->unk4F0 = p->motion.pos.f[2]; - if (p->state.prev_control_mode == 4) { + if (p->state.prev_control_mode == HERO_MODE_JUMP) { p->unk4EC = p->jump_gravity; p->unk4F0 = p->smoothed_ground_z; } @@ -2677,7 +2682,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ALT_LEDGE_HANG: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; if (b) set_hero_animation(0xA, 0, (float)scale_game_frames(6)); @@ -2685,7 +2690,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ALT_LEDGE_SHIMMY_YAW_PLUS_90: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; if (b) set_hero_animation(0xB, 0, (float)scale_game_frames(6)); @@ -2693,7 +2698,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_ALT_LEDGE_SHIMMY_YAW_MINUS_90: { struct Hero *p = &hero; - p->state.control_mode = 3; + p->state.control_mode = HERO_MODE_LEDGE; p->unk2284 = 0xD; if (b) set_hero_animation(0xC, 0, (float)scale_game_frames(6)); @@ -2701,7 +2706,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_2_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (b) set_hero_animation(0, 0, (float)scale_game_frames(0xF)); @@ -2709,7 +2714,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_2_REPEATABLE_SQUARE_ACTION: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unk2284 = 0; if (p->state.prev == 0x60 || (p->state.prev2 == 0x60 && scale_game_frames(0xA) > p->state.prev_timer)) { @@ -2730,7 +2735,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_2_COOLDOWN_ANIMATION_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unk2284 = 0; if (b) set_hero_animation(0xC, 0, (float)scale_game_frames(8)); @@ -2738,7 +2743,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_WAIT_FOR_CIRCLE_RELEASE_AND_ANIMATION: { struct Hero *p = &hero; - p->state.control_mode = 6; + p->state.control_mode = HERO_MODE_ATTACK; p->unk2284 = 0; if (b) set_hero_animation(8, 0, (float)scale_game_frames(8)); @@ -2746,7 +2751,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_2_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -2762,7 +2767,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_2_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; p->ground_speed = vector_length_xy(&p->motion.resolved_velocity); p->unk3B8 = 0; @@ -2772,7 +2777,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_2_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (b) @@ -2781,7 +2786,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_2_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -2795,7 +2800,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_3_IDLE: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (b) set_hero_animation(0, 0, (float)scale_game_frames(0xE)); @@ -2803,7 +2808,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_DELAYED_CIRCLE_RELEASE_WAIT: { struct Hero *p = &hero; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; p->unk2284 = 0; if (b) { set_hero_animation(4, 0, (float)scale_game_frames(7)); @@ -2813,7 +2818,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_3_SLIP: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; qcopy(&p->motion.velocity, &p->motion.resolved_velocity); if (b) @@ -2822,7 +2827,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_3_FALL: { struct Hero *p = &hero; - p->state.control_mode = 2; + p->state.control_mode = HERO_MODE_FALL; p->unk2284 = 0; p->fall_state_gravity = frame_time_sq * 24.0f; p->stickless_decel = frame_time_sq * 7.0f; @@ -2833,7 +2838,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_3_RUN: { struct Hero *p = &hero; - p->state.control_mode = 1; + p->state.control_mode = HERO_MODE_RUN; p->unk2284 = 0; { Vec4 *v = &p->motion.resolved_velocity; @@ -2851,7 +2856,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_3_DYING: { struct Hero *p = &hero; - p->state.control_mode = 0x14; + p->state.control_mode = HERO_MODE_DYING; p->unk2284 = 0; qcopy(&p->motion.momentum, &p->motion.resolved_velocity); if (b) @@ -2860,7 +2865,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_VEHICLE_MODE_3_HURT: { struct Hero *p = &hero; - p->state.control_mode = 7; + p->state.control_mode = HERO_MODE_HURT; p->unk2284 = 0; scale_hero_motion(0.5f); qcopy(&p->motion.velocity, &p->motion.resolved_velocity); @@ -2875,7 +2880,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_GRIND_COLLISION_RECOVERY: { struct Hero *p = &hero; - p->state.control_mode = 0xF; + p->state.control_mode = HERO_MODE_GRIND; p->unk2284 = 0; if (p->rail_off_frames == 0) hero_change_health(1); @@ -2902,7 +2907,7 @@ int hero_set_state(int requested_state, int b) { case HERO_STATE_LOOK_RELEASE_WAIT: { struct Hero *p = &hero; p->unk2284 = 0x51; - p->state.control_mode = 0; + p->state.control_mode = HERO_MODE_IDLE; if (return_hero_animation_id_unchanged(p->moby->prev_seq) != hero_idle_sequence(1)) { set_hero_animation(hero_idle_sequence(1), 0, (float)scale_game_frames(5)); } @@ -2926,7 +2931,7 @@ int hero_set_state(int requested_state, int b) { } case HERO_STATE_IDLE_ANIMATION_LONG_BLEND_ENTRY: { struct Hero *p = &hero; - p->state.control_mode = 8; + p->state.control_mode = HERO_MODE_ITEM_RELEASE_WAIT; p->unk2284 = 0; set_hero_animation(hero_idle_sequence(0), 0, (float)scale_game_frames(0xA)); break; @@ -2992,7 +2997,8 @@ int hero_set_state(int requested_state, int b) { } { struct Hero *t = &hero; - if (t->state.control_mode != 0xF && t->items[1].item_id == 0x1D && t->saved_item[1] != 0) { + if (t->state.control_mode != HERO_MODE_GRIND && t->items[1].item_id == 0x1D && + t->saved_item[1] != 0) { t->restore_item[1] = 1; } } @@ -3004,7 +3010,7 @@ int hero_set_state(int requested_state, int b) { } { struct Hero *t = &hero; - if (t->state.control_mode == 0x14) { + if (t->state.control_mode == HERO_MODE_DYING) { cancel_hero_item_animation(); t->item_use_locked = 1; } @@ -3087,7 +3093,7 @@ int try_enter_hero_water_state(void) { } water_surface_entry_pending = 0; if (hero_ptr->base_condition != 0) { - if (hero_ptr->state.control_mode == 0x11) { + if (hero_ptr->state.control_mode == HERO_MODE_SWIM) { if (hero_ptr->state.step != 1) { if (0.0f < hero_ptr->motion.displacement.f[2]) { if (hero_ptr->water_surface_z - 0.4f < hero_ptr->motion.pos.f[2]) { @@ -3095,14 +3101,16 @@ int try_enter_hero_water_state(void) { } } } - } else if (hero_ptr->state.control_mode != 0x12 && hero_ptr->state.control_mode != 3) { + } else if (hero_ptr->state.control_mode != HERO_MODE_WATER_SURFACE && + hero_ptr->state.control_mode != HERO_MODE_LEDGE) { surface_height_tolerance = 0.2f; if (surface_height_tolerance < absolute_float(hero_ptr->motion.velocity.f[2]) + 0.07f) { surface_height_tolerance = absolute_float(hero_ptr->motion.velocity.f[2]) + 0.07f; } if (absolute_float(hero_ptr->water_surface_z - (hero_ptr->motion.pos.f[2] + 0.45f)) < surface_height_tolerance) { - if (hero_ptr->state.control_mode != 4 || hero_ptr->past_jump_apex != 0) { + if (hero_ptr->state.control_mode != HERO_MODE_JUMP || + hero_ptr->past_jump_apex != 0) { if (0.8f < hero_ptr->water_depth && hero_ptr->motion.displacement.f[2] < 0.0f) { water_surface_entry_pending = 1; } @@ -3111,7 +3119,7 @@ int try_enter_hero_water_state(void) { hero_depth_check_ptr = &hero; if (hero_depth_check_ptr->motion.pos.f[2] < hero_depth_check_ptr->water_surface_z - 0.8f) { - if (hero_depth_check_ptr->state.control_mode != 4 || + if (hero_depth_check_ptr->state.control_mode != HERO_MODE_JUMP || hero_depth_check_ptr->past_jump_apex != 0) { water_surface_entry_pending = 1; } @@ -3132,8 +3140,8 @@ int try_enter_hero_water_state(void) { } hero_collision_check_ptr = &hero; if (hero_collision_check_ptr->state.control_mode - 0x11 >= 2u && - hero_collision_check_ptr->state.control_mode != 7 && - hero_collision_check_ptr->state.control_mode != 0x14 && + hero_collision_check_ptr->state.control_mode != HERO_MODE_HURT && + hero_collision_check_ptr->state.control_mode != HERO_MODE_DYING && hero_collision_check_ptr->state.current != 0x12 && (D_L00_0015F5CC & 0xF) == 0) { scale = 4.0f; if ((D_L00_0015F5CC & 0x3F) == 0) { diff --git a/src/overlays/shared/hero/hero_switch_item.c b/src/overlays/shared/hero/hero_switch_item.c index 06999b7f7f..59fe63e82d 100644 --- a/src/overlays/shared/hero/hero_switch_item.c +++ b/src/overlays/shared/hero/hero_switch_item.c @@ -258,7 +258,7 @@ void find_grind_rail(void) { hero.grind_rail = 0; if (hero.unk1C8 != 0) return; - if (current_level_index == 16) { + if (current_level_index == LEVEL_KALEBO3) { *(OvlQuad *)&proximity_or_rail_point = 0; proximity_or_rail_point.x = 115.0f; proximity_or_rail_point.y = 264.0f; @@ -271,7 +271,7 @@ void find_grind_rail(void) { if (12.0f < fast_vec_dist(&hero.motion.pos, &proximity_or_query_position)) return; } - } else if (current_level_index == 14) { + } else if (current_level_index == LEVEL_OLTANIS) { *(OvlQuad *)&proximity_or_rail_point = 0; proximity_or_rail_point.x = 157.0f; proximity_or_rail_point.y = 265.0f; @@ -290,7 +290,7 @@ void find_grind_rail(void) { return; } } - } else if (current_level_index == 6) { + } else if (current_level_index == LEVEL_NEBULA_G34) { *(OvlQuad *)&proximity_or_rail_point = 0; proximity_or_rail_point.x = 177.0f; proximity_or_rail_point.y = 304.0f; @@ -367,7 +367,8 @@ void update_hero_offset_rail_candidate(void) { if (P->rail_grab_cooldown != 0) return; compute_hero_fixed_offset_world_position(&rail_query_position); - if ((P->state.control_mode == 4 && P->past_jump_apex == 0) || P->state.control_mode == 2) { + if ((P->state.control_mode == HERO_MODE_JUMP && P->past_jump_apex == 0) || + P->state.control_mode == HERO_MODE_FALL) { pb = &rail_point; if (nearest_rail_point( &rail_query_position, &i20, pb, &i24, &rail_query_value, &i2C, 0, 0)) { @@ -713,7 +714,7 @@ void update_hero_condition_animation(void) { anim = 0x79; if (animation_selector_data && animation_selector_data[0x3C]) { anim = select_hero_condition_animation_id(animation_selector_data[0x3C]); - if (hero.state.control_mode == 1) + if (hero.state.control_mode == HERO_MODE_RUN) spd = 0.7f; } } @@ -731,7 +732,7 @@ void update_hero_condition_animation(void) { spd = 0.8f; anim = 0x7B; } - if (hero.state.control_mode == 0x11 && !D_0013D4C6_lui) { + if (hero.state.control_mode == HERO_MODE_SWIM && !D_0013D4C6_lui) { on = 1; anim = 0x78; condition_blend_base = @@ -1049,7 +1050,7 @@ void start_equipped_item_animation(void) { P->item_anim_item_id = item_id; hero_animation_id = item_defs[item_id].hero_animation; slot_animation_id = item_defs[item_id].animation; - if ((s32)P->state.control_mode == 12) + if ((s32)P->state.control_mode == HERO_MODE_CROUCH) slot_animation_id = item_defs[item_id].animation_mode_12; P->item_anim_active = 1; { @@ -1059,7 +1060,7 @@ void start_equipped_item_animation(void) { animation_step_divisor = scale_game_frames(10); if (item_defs[item_id].slot_anim_count == 0) animation_step_divisor = scale_game_frames(11); - if (P->state.control_mode == 0 && P->unk22C8 == 0) { + if (P->state.control_mode == HERO_MODE_IDLE && P->unk22C8 == 0) { P->item_hold_anim = hero_animation_id; set_hero_animation(hero_animation_id, 0, (f32)animation_step_divisor); return; @@ -1142,7 +1143,7 @@ void update_hero_held_items_and_orientation(void) { item_id = hero_slot_item_id(0); if (item_id == slot_owner->item_anim_item_id) { animation = item_defs_lui[item_id].animation; - if (slot_owner->state.control_mode == 12) { + if (slot_owner->state.control_mode == HERO_MODE_CROUCH) { animation = item_defs_lui[item_id].animation_mode_12; } if (animation != -1 && (*slot)[0x23] != animation) { @@ -1190,7 +1191,7 @@ void update_hero_held_items_and_orientation(void) { { struct Hero *pose_owner = &hero; - if (pose_owner->state.control_mode == 15) { + if (pose_owner->state.control_mode == HERO_MODE_GRIND) { char *target = (char *)pose_owner->grind_look_moby; if (target != 0) { @@ -2019,7 +2020,7 @@ void hero_switch_item(int i) { } } g = &hero; - if (g->state.control_mode == 0xF && D_0013D4C0[0x1D] != 0) { + if (g->state.control_mode == HERO_MODE_GRIND && D_0013D4C0[0x1D] != 0) { if (*(int *)(D_00141660 + 4) != 0x1D || *(int *)((char *)g + i * 0x50 + 0x10B8) == 0) { int v; g->pending_item[1] = 0x1D; @@ -2050,8 +2051,8 @@ void hero_switch_item(int i) { struct Hero *g = &hero; struct Hero *h; struct Hero *hero_state; - if (g->state.control_mode == 0x11 || g->state.current == 0x76 || g->state.current == 0x6A || - g->state.current == 0x82 || g->vent_updraft != 0) { + if (g->state.control_mode == HERO_MODE_SWIM || g->state.current == 0x76 || + g->state.current == 0x6A || g->state.current == 0x82 || g->vent_updraft != 0) { if (((int *)(D_00141660))[i] != 6 || (hero_state = &hero, *(int *)((char *)hero_state + i * 0x50 + 0x10B8) == 0)) { h = &hero; @@ -2313,7 +2314,7 @@ void update_hero_equipped_items(void) { hero.item_use_locked = 1; } if (hero_is_in_special_state() || hero.state.control_mode == 0x15 || - hero.state.control_mode == 0x16 || hero.state.control_mode == 3 || + hero.state.control_mode == 0x16 || hero.state.control_mode == HERO_MODE_LEDGE || hero.state.current == 0x12) { hero.unk20AE = 1; } else { @@ -2473,10 +2474,10 @@ s32 hero_check_damage(s32 apply_damage_response) { f32 horizontal_knockback_strength, vertical_knockback_strength, knockback_scale; V_210ce8 knockback_vector; - if (hero.state.control_mode == 0x14) { + if (hero.state.control_mode == HERO_MODE_DYING) { return 0; } - if (hero.state.control_mode == 7) { + if (hero.state.control_mode == HERO_MODE_HURT) { return 0; } if (hero.state.current == 0x32) { @@ -2507,7 +2508,7 @@ s32 hero_check_damage(s32 apply_damage_response) { D_0013DF88[current_level_index]++; hero.damage_source_moby = (struct Moby *)hero_hit_entry->source_moby; D_0015EEA8++; - if (hero.state.control_mode == 0xF) { + if (hero.state.control_mode == HERO_MODE_GRIND) { hero.unk5BE = 1; return 0; } @@ -2548,20 +2549,20 @@ s32 hero_check_damage(s32 apply_damage_response) { hero.motion.resolved_velocity_z.f[2] = frame_time * 7.0f; return 1; } - if (hero.state.control_mode == 0x12) { + if (hero.state.control_mode == HERO_MODE_WATER_SURFACE) { mob = ((u8 *)hero.damage_source_moby); if (mob != 0 && *(s16 *)(mob + 0xA6) == 0x28F) { id = 0x82; goto call_ret; } hero_set_state(0x75, 1); - } else if (hero.state.control_mode == 0x11) { + } else if (hero.state.control_mode == HERO_MODE_SWIM) { mob = ((u8 *)hero.damage_source_moby); if (mob != 0 && *(s16 *)(mob + 0xA6) == 0x28F) { id = 0x82; goto call_ret; } - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || current_level_index == LEVEL_VELDIN_ORBIT) { mob = ((u8 *)hero.damage_source_moby); if (mob != 0 && (*(s16 *)(mob + 0xA6) == 0x28F || *(s16 *)(mob + 0xA6) == 0x7B || *(s16 *)(mob + 0xA6) == 0x29D)) { @@ -2569,7 +2570,7 @@ s32 hero_check_damage(s32 apply_damage_response) { } } hero_set_state(0x76, 1); - } else if (hero.state.control_mode == 3) { + } else if (hero.state.control_mode == HERO_MODE_LEDGE) { mob = ((u8 *)hero.damage_source_moby); if (mob != 0) { id = 0x82; @@ -2694,7 +2695,7 @@ void update_hero_collision_capsule_dimensions(void) { hero.capsule_radius_target = 0.45f; break; } - if (hero.state.control_mode == 4) { + if (hero.state.control_mode == HERO_MODE_JUMP) { if (hero.state_timer > hero.takeoff_frame && hero.past_jump_apex == 0) hero.capsule_bottom_target = hero.unk434; } else if (hero.state.current == HERO_STATE_FALL) { @@ -2710,8 +2711,8 @@ void update_hero_collision_capsule_dimensions(void) { } else if (hero.state.current == HERO_STATE_SINK) { hero.capsule_radius_target = 0.8f; } - if (!hero.wall_hit || hero.state.prev_control_mode == 0x12 || hero.state.control_mode == 0x11 || - hero.base_condition || + if (!hero.wall_hit || hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE || + hero.state.control_mode == HERO_MODE_SWIM || hero.base_condition || vector_distance_xy(hero.wall_contact_point.f, hero.motion.pos.f) > hero.capsule_radius * 0.5f) { f32 *capsule_top_ptr = &hero.capsule_top; @@ -3362,7 +3363,7 @@ void update_hero_ground_contact_and_surface_slopes(void) { if (hero.gravity_mode) k = 1; ground_ray_start_offset = hero.capsule_radius * 2.2f; - if (hero.state.control_mode == 2) { + if (hero.state.control_mode == HERO_MODE_FALL) { ground_ray_start_offset = hero.capsule_radius * 2.9f; } hero_get_collision_ray_endpoints((Vec4_002126b8 *)&ground_ray_start, @@ -3389,7 +3390,7 @@ void update_hero_ground_contact_and_surface_slopes(void) { goto d1; } collision_sound_class = coll_sound_class(); - if (current_level_index == 1 || current_level_index == 0x12) { + if (current_level_index == LEVEL_NOVALIS || current_level_index == LEVEL_VELDIN2) { collision_sound_class = 3; } hero.ground_sound_class = collision_sound_class; @@ -3479,9 +3480,9 @@ void update_hero_ground_contact_and_surface_slopes(void) { hero.unk2C8.i[1] = 0; hero.unk2C0.i[0] = 0; hero.unk2C0.i[1] = 0; - if (hero.state.control_mode == 0xF || hero.state.control_mode == 0x15 || - hero.state.control_mode == 6 || hero.state.control_mode == 4 || - hero.state.control_mode == 5 || hero.state.control_mode == 3) { + if (hero.state.control_mode == HERO_MODE_GRIND || hero.state.control_mode == 0x15 || + hero.state.control_mode == HERO_MODE_ATTACK || hero.state.control_mode == HERO_MODE_JUMP || + hero.state.control_mode == HERO_MODE_LAND || hero.state.control_mode == HERO_MODE_LEDGE) { return; } if (!(hero.ground_distance < 0.25f)) { @@ -3680,7 +3681,7 @@ s32 resolve_hero_current_position_collisions(s32 mode) { resolve_hero_pending_path_clearance(); hero.path_constrain_pending = 0; } - if (hero.state.control_mode != 0x11) { + if (hero.state.control_mode != HERO_MODE_SWIM) { if (hero.gravity_mode != HERO_GRAVITY_WORLD_DOWN || hero.unk1F8 != 0) { if (hero.gravity_mode == HERO_GRAVITY_OPPOSITE_GROUND_NORMAL || hero.unk1F8 != 0) { add_hero_up_offset(&collision_probe_offset, &collision_probe_offset, 0.6f); @@ -3701,10 +3702,10 @@ s32 resolve_hero_current_position_collisions(s32 mode) { if (hero.gravity_mode != HERO_GRAVITY_WORLD_DOWN) { if (!coll_sphere(&hero.motion.pos.q, mask, ((s32)hero.moby), frame_scale * 0.4f)) break; - } else if (hero.state.control_mode == 0x11) { + } else if (hero.state.control_mode == HERO_MODE_SWIM) { if (!coll_sphere(&hero.motion.pos.q, mask, ((s32)hero.moby), 0.6f)) break; - } else if (hero.state.control_mode == 0xF) { + } else if (hero.state.control_mode == HERO_MODE_GRIND) { if (!coll_sphere(&hero.motion.pos.q, mask, ((s32)hero.moby), frame_scale * 0.45f)) break; } else { @@ -3842,7 +3843,7 @@ void apply_hero_motion_and_resolve_collisions(void) { } gravity_set_z(&hero.motion.velocity, &hero.motion.velocity, limit); } - } else if (hero.state.control_mode == 0xF) { + } else if (hero.state.control_mode == HERO_MODE_GRIND) { if (hero.collision_off_frames == 0) { velocity_measurement = vector_length_xy(&hero.motion.velocity); limit = hero.capsule_radius - 0.02f; @@ -3850,8 +3851,8 @@ void apply_hero_motion_and_resolve_collisions(void) { set_vector_length_xy(&hero.motion.velocity, &hero.motion.velocity, limit); } } - } else if (hero.state.control_mode != 0xD) { - if (hero.state.control_mode != 0xE && hero.collision_off_frames == 0) { + } else if (hero.state.control_mode != HERO_MODE_GRAPPLE) { + if (hero.state.control_mode != HERO_MODE_GRAPPLE_SWING && hero.collision_off_frames == 0) { velocity_measurement = fast_vec_length(&hero.motion.velocity); limit = hero.capsule_radius - 0.02f; if (limit < velocity_measurement) { @@ -4001,7 +4002,7 @@ void steer_hero_planar_velocity(f32 step) { case HERO_GRAVITY_WORLD_DOWN: yaw = player->motion.move_yaw; speed = player->target_speed; - if (player->state.control_mode == 4) { + if (player->state.control_mode == HERO_MODE_JUMP) { if (hero_ptr()->on_flagged_ground_moby == 0 && hero_ptr()->jump_blocked_ahead != 0 && hero_ptr()->wall_hit != 0) speed = frame_time * 2.1f; @@ -4093,7 +4094,7 @@ void air_accel(f32 step) { case HERO_GRAVITY_WORLD_DOWN: yaw = player->motion.move_yaw; speed = player->target_speed; - if (player->state.control_mode == 4) { + if (player->state.control_mode == HERO_MODE_JUMP) { if (hero_ptr()->on_flagged_ground_moby == 0 && hero_ptr()->jump_blocked_ahead != 0 && hero_ptr()->wall_hit != 0) speed = frame_time * 2.1f; diff --git a/src/overlays/shared/hero/hero_update_hop_movement.c b/src/overlays/shared/hero/hero_update_hop_movement.c index 70e8d08012..b6d6c11c07 100644 --- a/src/overlays/shared/hero/hero_update_hop_movement.c +++ b/src/overlays/shared/hero/hero_update_hop_movement.c @@ -172,7 +172,7 @@ void hero_update_hop_movement(void) { qcopy(&hero.motion.momentum, &hero.move_impulse); velocity_change_step = ED70 * 20.0f; if (hero.target_speed < hop_deceleration_speed_reference[0] * ED6C * 0.2f) { - if (hero.state.control_mode == 2) { + if (hero.state.control_mode == HERO_MODE_FALL) { speed_decay_step = hero.stickless_decel; if (hero.on_ice_ground) speed_decay_step = ED70 * 0.17f; diff --git a/src/overlays/shared/hero/hero_update_movement.c b/src/overlays/shared/hero/hero_update_movement.c index 3e02cf2322..be71170abf 100644 --- a/src/overlays/shared/hero/hero_update_movement.c +++ b/src/overlays/shared/hero/hero_update_movement.c @@ -1859,12 +1859,12 @@ void hero_update_movement(void) { f32 f; f32 old; f32 d; - if (current_level_index == 0xF) { + if (current_level_index == LEVEL_QUARTU) { release_voice_slot_cf(2, (struct MobyView *)hero.moby, 0x1D); } else { release_voice_slot_cf(2, (struct MobyView *)hero.moby, 6); } - if (current_level_index != 0xF) { + if (current_level_index != LEVEL_QUARTU) { emit_hero_randomized_motion_effects(4, 2); movement_and_hit_descriptor_scratch.f[0] = hero.motion.pos.f[0] + random_float_between(-0.25f, 0.25f); diff --git a/src/overlays/shared/hero/hero_update_transitions.c b/src/overlays/shared/hero/hero_update_transitions.c index 099bccd156..1986736124 100644 --- a/src/overlays/shared/hero/hero_update_transitions.c +++ b/src/overlays/shared/hero/hero_update_transitions.c @@ -192,7 +192,7 @@ void hero_update_transitions(void) { prevState = hero.state.step; prevAnim = MOBY(moby)->prev_seq; if (hero_check_damage(1) == 0) { - if (hero.health.hp <= 0 && hero.state.control_mode != 0x14 && + if (hero.health.hp <= 0 && hero.state.control_mode != HERO_MODE_DYING && (hero.state.current == HERO_STATE_IDLE || hero.state.current == HERO_STATE_RUN)) { hero_set_state(HERO_STATE_DYING, 1); } else if (process_hero_equipped_item_input() == 0 && try_enter_hero_water_state() == 0 && @@ -470,7 +470,7 @@ void hero_update_transitions(void) { } } if (ok && 0.22f < hero.stick_magnitude) { - if (current_level_index == 0xC) { + if (current_level_index == LEVEL_HOVEN) { int slot = hero.ground_sound_class; emit_hero_animation_voice_and_ground_particle(slot, 0, 0); emit_hero_animation_voice_and_ground_particle(slot, 1, 0); @@ -660,7 +660,8 @@ void hero_update_transitions(void) { break; case HERO_STATE_HURT_WITH_DISPLACEMENT_VELOCITY: if (hero.health.hp <= 0) { - if (current_level_index == 0xF || current_level_index == 0x11) { + if (current_level_index == LEVEL_QUARTU || + current_level_index == LEVEL_VELDIN_ORBIT) { hero_set_state(0x82, 1); break; } @@ -846,7 +847,8 @@ void hero_update_transitions(void) { break; } if (!(hero.air_frames.s < scale_game_frames(5)) && - !(hero.state.prev_control_mode == 0x12 && hero.wading != 0) && + !(hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE && + hero.wading != 0) && hero.ground_distance > 1.35f) { if (check_hero_forward_collision_height() == 0) { hero_set_state(HERO_STATE_FALL, 1); @@ -940,7 +942,8 @@ void hero_update_transitions(void) { break; } if (hero.state_timer > scale_game_frames(0xF) || - (hero.state.prev_control_mode != 0 && hero.state.prev_control_mode != 1)) { + (hero.state.prev_control_mode != HERO_MODE_IDLE && + hero.state.prev_control_mode != HERO_MODE_RUN)) { if ((controller_state.pressed & 0x10000) && hero.unk20AA == 0) { hero.unk3BE = 1; } @@ -1367,7 +1370,7 @@ void hero_update_transitions(void) { float len; grab = 0; - if (current_level_index == 0x10 && hero.wall_hit != 0) { + if (current_level_index == LEVEL_KALEBO3 && hero.wall_hit != 0) { unsigned char *m = ((unsigned char *)hero.coll_hit_moby); if (m != 0 && *(short *)(m + 0xA6) == 0x101) { grab = 1; @@ -1379,7 +1382,7 @@ void hero_update_transitions(void) { hero.unk5BE != 0) { int ok = 1; - if (current_level_index != 0x10) { + if (current_level_index != LEVEL_KALEBO3) { qcopy(position_scratch, hero.rail_point.f); position_scratch[2] += 2.0f; spatial_vector_scratch[0] = fast_cos(hero.rail_dir_yaw) * 5.0f; @@ -1432,7 +1435,7 @@ void hero_update_transitions(void) { if (hero.state.current == HERO_STATE_GRIND) { int go = 1; - if (current_level_index == 8) { + if (current_level_index == LEVEL_BATALIA) { *(OvlQuad *)position_scratch = 0; position_scratch[0] = 342.0f; position_scratch[1] = 111.1f; @@ -1958,9 +1961,9 @@ void hero_update_transitions(void) { } break; case HERO_STATE_FATAL_FALL: - if ((current_level_index == 3 && 5.0f > hero.motion.pos.f[2]) || - (current_level_index == 6 && 50.0f > hero.motion.pos.f[2]) || - (current_level_index == 0x10 && + if ((current_level_index == LEVEL_KERWAN && 5.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_NEBULA_G34 && 50.0f > hero.motion.pos.f[2]) || + (current_level_index == LEVEL_KALEBO3 && (77.0f > hero.motion.pos.f[2] || (hero.state_timer > 0x14 && hero.wall_hit != 0 && hero.motion.displacement.f[2] >= 0.0f))) || @@ -2472,8 +2475,8 @@ void hero_update_transitions(void) { hero_set_state(HERO_STATE_FALL, 1); break; } - if (current_level_index == 0x10 && 0.0f > hero.motion.velocity.f[2] && - hero.health.hp == 0 && hero.state.prev_control_mode == 0xF) { + if (current_level_index == LEVEL_KALEBO3 && 0.0f > hero.motion.velocity.f[2] && + hero.health.hp == 0 && hero.state.prev_control_mode == HERO_MODE_GRIND) { hero_set_state(0x77, 1); break; } @@ -2701,7 +2704,7 @@ void hero_update_transitions(void) { } break; case HERO_STATE_VEHICLE_MODE_1_FALL: - if (current_level_index == 6 && 115.0f > hero.motion.pos.f[2]) { + if (current_level_index == LEVEL_NEBULA_G34 && 115.0f > hero.motion.pos.f[2]) { goto respawn; } if (hero.air_frames.s == 0) { diff --git a/src/overlays/shared/hero/process_hero_item_action_input.c b/src/overlays/shared/hero/process_hero_item_action_input.c index 657b26bb8a..6e20cb162a 100644 --- a/src/overlays/shared/hero/process_hero_item_action_input.c +++ b/src/overlays/shared/hero/process_hero_item_action_input.c @@ -98,8 +98,8 @@ void integrate_hero_movement(void) { } gravity_set_z(&hero.motion.velocity, &hero.motion.velocity, limit); } - } else if (hero.state.control_mode != 0xD) { - if (hero.state.control_mode != 0xE && hero.collision_off_frames == 0) { + } else if (hero.state.control_mode != HERO_MODE_GRAPPLE) { + if (hero.state.control_mode != HERO_MODE_GRAPPLE_SWING && hero.collision_off_frames == 0) { velocity_measure = fast_vec_length(&hero.motion.velocity); limit = hero.capsule_radius - 0.02f; if (limit < velocity_measure) { @@ -329,7 +329,7 @@ void hero_update_hop_velocity(void) { qcopy(&hero.motion.momentum, &hero.move_impulse); velocity_change_step = ED70 * 20.0f; if (hero.target_speed < hero_low_speed_threshold_basis[0] * ED6C * 0.2f) { - if (hero.state.control_mode == 2) { + if (hero.state.control_mode == HERO_MODE_FALL) { speed_reduction_step = hero.stickless_decel; speed = vector_length_xy(&hero.motion.velocity); approach_value(0.0f, speed_reduction_step, &speed); @@ -429,8 +429,8 @@ s32 process_hero_item_action_input(void) { switch (hero.items[0].item_id) { case HERO_ITEM_WRENCH: - if (hero.state.control_mode == 0 || hero.state.control_mode == 1 || - (hero.state.control_mode == 4 && hero.rail_land_frames != 0)) { + if (hero.state.control_mode == HERO_MODE_IDLE || hero.state.control_mode == HERO_MODE_RUN || + (hero.state.control_mode == HERO_MODE_JUMP && hero.rail_land_frames != 0)) { if (hero.on_slip_ground == 0 && pad_pressed_within(buttons, scale_game_frames(7), &wrench_press_age_frames) != 0) { moby = hero.items[0].moby; @@ -475,7 +475,7 @@ s32 process_hero_item_action_input(void) { hero_set_state(HERO_STATE_WRENCH_COMBO, 1); } } - } else if (hero.state.control_mode == 6) { + } else if (hero.state.control_mode == HERO_MODE_ATTACK) { row = &D_L02_0017C228[hero.attack_record]; if (hero.state.current == HERO_STATE_CROUCH_SWING && scale_game_frames(0x1E) < hero.state_timer && hero.anim_changing == 0 && @@ -510,10 +510,11 @@ s32 process_hero_item_action_input(void) { if (hero.air_frames.s != 0) { window = scale_game_frames(8); } - if (hero.state.control_mode == 0 || hero.state.control_mode == 1 || - hero.state.control_mode == 4 || hero.state.control_mode == 2 || - hero.state.control_mode == 0xF || hero.state.control_mode == 5 || - hero.state.current == 0x1E) { + if (hero.state.control_mode == HERO_MODE_IDLE || hero.state.control_mode == HERO_MODE_RUN || + hero.state.control_mode == HERO_MODE_JUMP || + hero.state.control_mode == HERO_MODE_FALL || + hero.state.control_mode == HERO_MODE_GRIND || + hero.state.control_mode == HERO_MODE_LAND || hero.state.current == 0x1E) { if (pad_pressed_within(buttons, window, NULL) != 0 || ((controller_state.held & buttons) && hero.items[0].ready_frames > scale_game_frames(0xF))) { @@ -549,19 +550,23 @@ s32 process_hero_item_action_input(void) { break; case HERO_ITEM_BUFFERED_ACTIVATE: - if ((hero.state.control_mode == 0 || hero.state.control_mode == 1 || - hero.state.control_mode == 2 || hero.state.control_mode == 4 || - hero.state.control_mode == 5) && + if ((hero.state.control_mode == HERO_MODE_IDLE || + hero.state.control_mode == HERO_MODE_RUN || + hero.state.control_mode == HERO_MODE_FALL || + hero.state.control_mode == HERO_MODE_JUMP || + hero.state.control_mode == HERO_MODE_LAND) && pad_pressed_within(buttons, scale_game_frames(8), NULL) != 0) { open_vendor_menu(0); } break; case HERO_ITEM_HOLD_TO_FIRE: - if (hero.state.control_mode == 0 || hero.state.control_mode == 1 || - hero.state.control_mode == 0xC || hero.state.control_mode == 2 || - hero.state.control_mode == 4 || hero.state.control_mode == 5 || - hero.state.control_mode == 0xF || hero.state.current == 0x1E) { + if (hero.state.control_mode == HERO_MODE_IDLE || hero.state.control_mode == HERO_MODE_RUN || + hero.state.control_mode == HERO_MODE_CROUCH || + hero.state.control_mode == HERO_MODE_FALL || + hero.state.control_mode == HERO_MODE_JUMP || + hero.state.control_mode == HERO_MODE_LAND || + hero.state.control_mode == HERO_MODE_GRIND || hero.state.current == 0x1E) { if (hero.items[0].moby != NULL) { held_gadget_voice_state = (struct HeldGadgetVars *)hero.items[0].moby->pvars; if ((((controller_state.held & buttons) && @@ -586,10 +591,12 @@ s32 process_hero_item_action_input(void) { case HERO_ITEM_BUFFERED_OR_TIMED_HOLD_ACTIVATE_WITH_VOICE: case HERO_ITEM_AMMO_GATED_BUFFERED_OR_TIMED_HOLD_ACTIVATE_WITH_VOICE: case HERO_ITEM_BUFFERED_OR_TIMED_HOLD_ACTIVATE_WITH_EMPTY_AMMO_VOICE: - if ((hero.state.control_mode == 0 && hero.state.current != 0x1E) || - hero.state.control_mode == 1 || hero.state.control_mode == 0xC || - hero.state.control_mode == 5 || hero.state.control_mode == 0xF || - (hero.state.control_mode == 4 && hero.unk4AC != 0) || + if ((hero.state.control_mode == HERO_MODE_IDLE && hero.state.current != 0x1E) || + hero.state.control_mode == HERO_MODE_RUN || + hero.state.control_mode == HERO_MODE_CROUCH || + hero.state.control_mode == HERO_MODE_LAND || + hero.state.control_mode == HERO_MODE_GRIND || + (hero.state.control_mode == HERO_MODE_JUMP && hero.unk4AC != 0) || (hero.state.current == 0x23 && hero.anim_frame > 25.0f)) { if (hero.item_anim_active == 0) { s32 hold; @@ -603,9 +610,11 @@ s32 process_hero_item_action_input(void) { ((controller_state.held & 0x20) && scale_game_frames(8) < hold && hold < scale_game_frames(0x11))) { if (get_ammo(-1) != 0) { - if (hero.state.control_mode == 0xC || hero.state.control_mode == 0 || + if (hero.state.control_mode == HERO_MODE_CROUCH || + hero.state.control_mode == HERO_MODE_IDLE || hero.state.current == HERO_STATE_STOP || - (hero.state.control_mode == 1 && hero.stick_magnitude < 0.7f)) { + (hero.state.control_mode == HERO_MODE_RUN && + hero.stick_magnitude < 0.7f)) { hero_set_state(0x23, 1); } else { start_equipped_item_animation(); @@ -619,8 +628,8 @@ s32 process_hero_item_action_input(void) { break; case HERO_ITEM_BUFFERED_ACTIVATE_WITH_VOICE: - if (hero.state.control_mode == 0 || hero.state.control_mode == 1 || - (hero.state.control_mode == 4 && hero.rail_land_frames != 0)) { + if (hero.state.control_mode == HERO_MODE_IDLE || hero.state.control_mode == HERO_MODE_RUN || + (hero.state.control_mode == HERO_MODE_JUMP && hero.rail_land_frames != 0)) { if (hero.state.current != HERO_STATE_LOOK) { s32 limit; s32 hold; @@ -652,9 +661,11 @@ s32 process_hero_item_action_input(void) { (hero.unk308 == 0 || D_0013D4DC[0] == 0) && hero.pack_disabled == 0) { fast_dec_timer(&hero_button_8_double_press_countdown_gp); if (hero_button_8_double_press_countdown_gp != 0) { - if (hero.state.control_mode == 0 || hero.state.control_mode == 1 || - hero.state.control_mode == 0xC || - ((hero.state.control_mode == 2 || hero.state.control_mode == 4) && + if (hero.state.control_mode == HERO_MODE_IDLE || + hero.state.control_mode == HERO_MODE_RUN || + hero.state.control_mode == HERO_MODE_CROUCH || + ((hero.state.control_mode == HERO_MODE_FALL || + hero.state.control_mode == HERO_MODE_JUMP) && hero.grounded_frames != 0)) { if ((controller_state.held & 8) && (controller_state.pressed & 8)) { hero_set_state(0x81, 1); diff --git a/src/overlays/shared/hero/process_hero_primary_item_input.c b/src/overlays/shared/hero/process_hero_primary_item_input.c index 8990ebb7d5..d6ffd958c4 100644 --- a/src/overlays/shared/hero/process_hero_primary_item_input.c +++ b/src/overlays/shared/hero/process_hero_primary_item_input.c @@ -1,5 +1,6 @@ /* Hero: primary item input, item slot selection, water and ground transitions, and the hoverboard tricks, race progress and respawn. */ #include "types.h" +#include "rnc/world/level_id.h" #include "rnc/input/pad_state.h" #include "rnc/mobys/moby.h" #include "rnc/overlay/shared/hero/hero_tables.h" @@ -224,7 +225,7 @@ void apply_hero_item_slot_selection(int i) { } } g = &hero; - if (g->state.control_mode == 0xF && item_available_lui[0x1D] != 0) { + if (g->state.control_mode == HERO_MODE_GRIND && item_available_lui[0x1D] != 0) { if (*(int *)(D_00141660 + 4) != 0x1D || *(int *)((char *)g + i * 0x50 + 0x10B8) == 0) { int v; g->pending_item[1] = 0x1D; @@ -255,8 +256,9 @@ void apply_hero_item_slot_selection(int i) { struct Hero *g = &hero; struct Hero *h; struct Hero *equipped_item_check_hero; - if (g->state.control_mode == 0x11 || g->state.current == 0x76 || g->state.current == 0x6A || - g->state.current == 0x82 || *(unsigned char *)((char *)g + 0x22CB) != 0) { + if (g->state.control_mode == HERO_MODE_SWIM || g->state.current == 0x76 || + g->state.current == 0x6A || g->state.current == 0x82 || + *(unsigned char *)((char *)g + 0x22CB) != 0) { if (((int *)(D_00141660))[i] != 6 || (equipped_item_check_hero = &hero, *(int *)((char *)equipped_item_check_hero + i * 0x50 + 0x10B8) == 0)) { @@ -560,7 +562,7 @@ int try_apply_hero_water_and_ground_transitions(void) { } water_state_requested = 0; if (hero_ptr->base_condition != 0) { - if (hero_ptr->state.control_mode == 0x11) { + if (hero_ptr->state.control_mode == HERO_MODE_SWIM) { if (hero_ptr->state.step != 1) { if (0.0f < hero_ptr->motion.displacement.f[2]) { if (hero_ptr->water_surface_z - 0.4f < hero_ptr->motion.pos.f[2]) { @@ -568,14 +570,16 @@ int try_apply_hero_water_and_ground_transitions(void) { } } } - } else if (hero_ptr->state.control_mode != 0x12 && hero_ptr->state.control_mode != 3) { + } else if (hero_ptr->state.control_mode != HERO_MODE_WATER_SURFACE && + hero_ptr->state.control_mode != HERO_MODE_LEDGE) { water_surface_tolerance = 0.2f; if (water_surface_tolerance < absolute_float(hero_ptr->motion.velocity.f[2]) + 0.07f) { water_surface_tolerance = absolute_float(hero_ptr->motion.velocity.f[2]) + 0.07f; } if (absolute_float(hero_ptr->water_surface_z - (hero_ptr->motion.pos.f[2] + 0.45f)) < water_surface_tolerance) { - if (hero_ptr->state.control_mode != 4 || hero_ptr->past_jump_apex != 0) { + if (hero_ptr->state.control_mode != HERO_MODE_JUMP || + hero_ptr->past_jump_apex != 0) { if (0.8f < hero_ptr->water_depth && hero_ptr->motion.displacement.f[2] < 0.0f) { water_state_requested = 1; } @@ -583,7 +587,7 @@ int try_apply_hero_water_and_ground_transitions(void) { } depth_check_hero = &hero; if (depth_check_hero->motion.pos.f[2] < depth_check_hero->water_surface_z - 0.8f) { - if (depth_check_hero->state.control_mode != 4 || + if (depth_check_hero->state.control_mode != HERO_MODE_JUMP || depth_check_hero->past_jump_apex != 0) { water_state_requested = 1; } @@ -604,8 +608,8 @@ int try_apply_hero_water_and_ground_transitions(void) { } collision_check_hero = &hero; if (collision_check_hero->state.control_mode - 0x11 >= 2u && - collision_check_hero->state.control_mode != 7 && - collision_check_hero->state.control_mode != 0x14 && + collision_check_hero->state.control_mode != HERO_MODE_HURT && + collision_check_hero->state.control_mode != HERO_MODE_DYING && collision_check_hero->state.current != 0x12 && (frame_number & 0xF) == 0) { scale = 4.0f; if ((frame_number & 0x3F) == 0) { @@ -712,7 +716,7 @@ int process_hero_primary_item_input(void) { switch ((*(Hero *)((char *)&hero)).items[0].item_id) { case ITEM_WRENCH: if ((*(Hero *)((char *)&hero)).state.control_mode < 2U || - ((*(Hero *)((char *)&hero)).state.control_mode == 4 && + ((*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_JUMP && (*(Hero *)((char *)&hero)).rail_land_frames != 0)) { Moby *item; @@ -792,7 +796,7 @@ int process_hero_primary_item_input(void) { break; } } - if ((*(Hero *)((char *)&hero)).state.control_mode == 6) { + if ((*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_ATTACK) { HeroTableRow2C *wrench_attack_timing_record = &D_L05_0017C088[(*(Hero *)((char *)&hero)).attack_record]; int window; @@ -854,10 +858,10 @@ int process_hero_primary_item_input(void) { window = scale_game_frames(8); } if ((*(Hero *)((char *)&hero)).state.control_mode < 2U || - (*(Hero *)((char *)&hero)).state.control_mode == 4 || - (*(Hero *)((char *)&hero)).state.control_mode == 2 || - (*(Hero *)((char *)&hero)).state.control_mode == 0xF || - (*(Hero *)((char *)&hero)).state.control_mode == 5 || + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_JUMP || + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_FALL || + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_GRIND || + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_LAND || (*(Hero *)((char *)&hero)).state.current == 0x1E) { if (pad_pressed_within(mask, window, 0) || ((controller_state.held & mask) && @@ -910,8 +914,8 @@ int process_hero_primary_item_input(void) { break; case ITEM_AMMO_MENU_DEVICE: if ((*(Hero *)((char *)&hero)).state.control_mode < 3U || - (*(Hero *)((char *)&hero)).state.control_mode == 4 || - (*(Hero *)((char *)&hero)).state.control_mode == 5) { + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_JUMP || + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_LAND) { if (pad_pressed_within(mask, scale_game_frames(8), 0)) { open_vendor_menu(0); } @@ -919,11 +923,11 @@ int process_hero_primary_item_input(void) { break; case ITEM_HELD_SOUND_DEVICE: if ((*(Hero *)((char *)&hero)).state.control_mode < 2U || - (*(Hero *)((char *)&hero)).state.control_mode == 0xC || - (*(Hero *)((char *)&hero)).state.control_mode == 2 || - (*(Hero *)((char *)&hero)).state.control_mode == 4 || - (*(Hero *)((char *)&hero)).state.control_mode == 5 || - (*(Hero *)((char *)&hero)).state.control_mode == 0xF || + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_CROUCH || + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_FALL || + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_JUMP || + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_LAND || + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_GRIND || (*(Hero *)((char *)&hero)).state.current == 0x1E) { PVar *pv; @@ -957,13 +961,13 @@ int process_hero_primary_item_input(void) { case 20: case 24: case 25: - if (((*(Hero *)((char *)&hero)).state.control_mode == 0 && + if (((*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_IDLE && (*(Hero *)((char *)&hero)).state.current != 0x1E) || - (*(Hero *)((char *)&hero)).state.control_mode == 1 || - (*(Hero *)((char *)&hero)).state.control_mode == 0xC || - (*(Hero *)((char *)&hero)).state.control_mode == 5 || - (*(Hero *)((char *)&hero)).state.control_mode == 0xF || - ((*(Hero *)((char *)&hero)).state.control_mode == 4 && + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_RUN || + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_CROUCH || + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_LAND || + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_GRIND || + ((*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_JUMP && (*(Hero *)((char *)&hero)).unk4AC != 0) || ((*(Hero *)((char *)&hero)).state.current == 0x23 && (*(Hero *)((char *)&hero)).anim_frame > 25.0f)) { @@ -980,10 +984,10 @@ int process_hero_primary_item_input(void) { ((controller_state.held & 0x20) && held_frames > scale_game_frames(8) && held_frames < scale_game_frames(0x11))) { if (get_ammo(-1)) { - if ((*(Hero *)((char *)&hero)).state.control_mode == 0xC || - (*(Hero *)((char *)&hero)).state.control_mode == 0 || + if ((*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_CROUCH || + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_IDLE || (*(Hero *)((char *)&hero)).state.current == 3 || - ((*(Hero *)((char *)&hero)).state.control_mode == 1 && + ((*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_RUN && (*(Hero *)((char *)&hero)).stick_magnitude < 0.7f)) { hero_set_state(0x23, 1); } else { @@ -1000,7 +1004,7 @@ int process_hero_primary_item_input(void) { break; case ITEM_STATE_CHANGING_SOUND_DEVICE: if ((*(Hero *)((char *)&hero)).state.control_mode < 2U || - ((*(Hero *)((char *)&hero)).state.control_mode == 4 && + ((*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_JUMP && (*(Hero *)((char *)&hero)).rail_land_frames != 0)) { if ((*(Hero *)((char *)&hero)).state.current != 1) { int window = scale_game_frames(0xA); @@ -1127,9 +1131,9 @@ int process_hero_primary_item_input(void) { fast_dec_timer(&hero_item_input_r1_double_press_timer_gp); if (hero_item_input_r1_double_press_timer_gp != 0) { if ((*(Hero *)((char *)&hero)).state.control_mode < 2U || - (*(Hero *)((char *)&hero)).state.control_mode == 0xC || - (((*(Hero *)((char *)&hero)).state.control_mode == 2 || - (*(Hero *)((char *)&hero)).state.control_mode == 4) && + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_CROUCH || + (((*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_FALL || + (*(Hero *)((char *)&hero)).state.control_mode == HERO_MODE_JUMP) && (*(Hero *)((char *)&hero)).grounded_frames != 0)) { if ((controller_state.held & 8) && (controller_state.pressed & 8)) { hero_set_state(0x81, 1); @@ -1963,8 +1967,8 @@ int hero_pick_help_mode(void) { return 1; continue_fall: if (alternate_item_available_lui[0]) { - if (current_level_index == 5 && (&hero)->tricks_landed[4] == 4 && (&hero)->unk70C > 3 && - item_unlocked_lui[7] == 0) { + if (current_level_index == LEVEL_RILGAR && (&hero)->tricks_landed[4] == 4 && + (&hero)->unk70C > 3 && item_unlocked_lui[7] == 0) { item_unlocked_lui[7] = 1; allocate_voice_for_bank_entry(1, 0, 0); queue_dialogue_message(0x53D6, -1); diff --git a/src/overlays/shared/hero/set_hero_animation.c b/src/overlays/shared/hero/set_hero_animation.c index 25b7da41c1..f441aabad8 100644 --- a/src/overlays/shared/hero/set_hero_animation.c +++ b/src/overlays/shared/hero/set_hero_animation.c @@ -141,7 +141,7 @@ void blend_hero_slot3_mapped_animation_pair(int id, int frame_index, float blend } blk2 = &hero; ok = 1; - if (blk2->state.control_mode == 0 && + if (blk2->state.control_mode == HERO_MODE_IDLE && lookup_hero_slot3_animation_key(MOBY(slot3_moby)->prev_seq, &id) != 0) { if (id == 0) { ok = 0; diff --git a/src/overlays/shared/hero/try_transition_hero_water_state.c b/src/overlays/shared/hero/try_transition_hero_water_state.c index 891544d62e..e58484c247 100644 --- a/src/overlays/shared/hero/try_transition_hero_water_state.c +++ b/src/overlays/shared/hero/try_transition_hero_water_state.c @@ -29,7 +29,7 @@ int try_transition_hero_water_state(void) { int decrement; int state; - if (hero.state.control_mode == 0x11) { + if (hero.state.control_mode == HERO_MODE_SWIM) { if (item_available[6] != 0) { decrement = 0; } else { @@ -62,7 +62,7 @@ int try_transition_hero_water_state(void) { hero.underwater_air = 10000; } collision_mode: - if (hero.state.control_mode != 0x12) + if (hero.state.control_mode != HERO_MODE_WATER_SURFACE) return 0; qcopy(&start, &hero.motion.pos); start.f[2] = hero.water_surface_z + 0.01f; diff --git a/src/overlays/shared/hero/update_hero_and_vehicle_mode_effects.c b/src/overlays/shared/hero/update_hero_and_vehicle_mode_effects.c index df07a6f1e8..b13e89cf23 100644 --- a/src/overlays/shared/hero/update_hero_and_vehicle_mode_effects.c +++ b/src/overlays/shared/hero/update_hero_and_vehicle_mode_effects.c @@ -297,7 +297,7 @@ void update_hero_smoothing_parameters(void) { hero.capsule_radius_target = 0.45f; break; } - if (hero.state.control_mode == 4) { + if (hero.state.control_mode == HERO_MODE_JUMP) { if (hero.state_timer > hero.takeoff_frame && hero.past_jump_apex == 0) hero.capsule_bottom_target = hero.unk434; } else if (hero.state.current == HERO_STATE_FALL) { @@ -310,8 +310,8 @@ void update_hero_smoothing_parameters(void) { } else if (hero.state.current == HERO_STATE_SINK) { hero.capsule_radius_target = 0.8f; } - if (!hero.wall_hit || hero.state.prev_control_mode == 0x12 || hero.state.control_mode == 0x11 || - hero.base_condition || + if (!hero.wall_hit || hero.state.prev_control_mode == HERO_MODE_WATER_SURFACE || + hero.state.control_mode == HERO_MODE_SWIM || hero.base_condition || vector_distance_xy(hero.wall_contact_point.f, hero.motion.pos.f) > hero.capsule_radius * 0.5f) { f32 *smoothing_state = D_0013F570; diff --git a/src/overlays/shared/hero/update_hero_ground_contact.c b/src/overlays/shared/hero/update_hero_ground_contact.c index 24953985e3..9557cadc6e 100644 --- a/src/overlays/shared/hero/update_hero_ground_contact.c +++ b/src/overlays/shared/hero/update_hero_ground_contact.c @@ -125,7 +125,7 @@ void update_hero_ground_contact(void) { if (hero.gravity_mode) k = 1; ground_ray_endpoint_offset = hero.capsule_radius * 2.2f; - if (hero.state.control_mode == 2) { + if (hero.state.control_mode == HERO_MODE_FALL) { ground_ray_endpoint_offset = hero.capsule_radius * 2.9f; } hero_get_collision_ray_endpoints( @@ -149,7 +149,7 @@ void update_hero_ground_contact(void) { goto d1; } collision_sound_class = coll_sound_class(); - if (current_level_index == 1 || current_level_index == 0x12) { + if (current_level_index == LEVEL_NOVALIS || current_level_index == LEVEL_VELDIN2) { collision_sound_class = 3; } hero.ground_sound_class = collision_sound_class; @@ -229,9 +229,9 @@ void update_hero_ground_contact(void) { hero.unk2C8.i[1] = 0; hero.unk2C0.i[0] = 0; hero.unk2C0.i[1] = 0; - if (hero.state.control_mode == 0xF || hero.state.control_mode == 0x15 || - hero.state.control_mode == 6 || hero.state.control_mode == 4 || - hero.state.control_mode == 5 || hero.state.control_mode == 3) { + if (hero.state.control_mode == HERO_MODE_GRIND || hero.state.control_mode == 0x15 || + hero.state.control_mode == HERO_MODE_ATTACK || hero.state.control_mode == HERO_MODE_JUMP || + hero.state.control_mode == HERO_MODE_LAND || hero.state.control_mode == HERO_MODE_LEDGE) { return; } if (!(hero.ground_distance < 0.25f)) { diff --git a/src/overlays/shared/hero/update_hero_vehicle_attachments_and_effects.c b/src/overlays/shared/hero/update_hero_vehicle_attachments_and_effects.c index 9a35d79658..b8809493dd 100644 --- a/src/overlays/shared/hero/update_hero_vehicle_attachments_and_effects.c +++ b/src/overlays/shared/hero/update_hero_vehicle_attachments_and_effects.c @@ -582,7 +582,7 @@ s32 resolve_hero_position_collisions(s32 mode) { resolve_hero_pending_path_clearance(); hero.path_constrain_pending = 0; } - if (hero.state.control_mode != 0x11) { + if (hero.state.control_mode != HERO_MODE_SWIM) { if (hero.gravity_mode != HERO_GRAVITY_WORLD_DOWN || hero.unk1F8 != 0) { if (hero.gravity_mode == HERO_GRAVITY_OPPOSITE_GROUND_NORMAL || hero.unk1F8 != 0) { add_hero_up_offset(&collision_query_offset, &collision_query_offset, 0.6f); @@ -602,7 +602,7 @@ s32 resolve_hero_position_collisions(s32 mode) { if (hero.gravity_mode != HERO_GRAVITY_WORLD_DOWN) { if (!coll_sphere(&hero.motion.pos.q, mask, hero.moby, frame_scale * 0.4f)) break; - } else if (hero.state.control_mode == 0xF) { + } else if (hero.state.control_mode == HERO_MODE_GRIND) { if (!coll_sphere(&hero.motion.pos.q, mask, hero.moby, frame_scale * 0.45f)) break; } else { diff --git a/src/overlays/shared/mobys/camera_object.c b/src/overlays/shared/mobys/camera_object.c index 715de57e6d..e99e094dc9 100644 --- a/src/overlays/shared/mobys/camera_object.c +++ b/src/overlays/shared/mobys/camera_object.c @@ -57,9 +57,9 @@ void camera_object_update(char *camera_object) { G_2a4e48 *P; float dot_product_or_threshold; - if (C->unk180 != 0) { + if (C->current_camera != 0) { object_position = camera_object + 0x10; - qcopy(object_position, (char *)C->unk180 + 0x30); + qcopy(object_position, (char *)C->current_camera + 0x30); pos = (char *)&hero.motion.pos; fast_vec_sub(difference_vector, object_position, pos); P = (G_2a4e48 *)(pos - 0x80); diff --git a/src/overlays/shared/mobys/is_hero_on_moby.c b/src/overlays/shared/mobys/is_hero_on_moby.c index 9cc7e92229..0a61c9f743 100644 --- a/src/overlays/shared/mobys/is_hero_on_moby.c +++ b/src/overlays/shared/mobys/is_hero_on_moby.c @@ -18,7 +18,7 @@ s32 is_hero_on_moby(struct Moby *candidate_moby) __asm__("FUN_L01_00277fb8"); s32 is_hero_on_moby(struct Moby *candidate_moby) { struct Hero *hero_ptr = &hero; - if (hero_ptr->state.control_mode == 3 || hero_ptr->state.current == 0x1C) { + if (hero_ptr->state.control_mode == HERO_MODE_LEDGE || hero_ptr->state.current == 0x1C) { if ((struct Moby *)hero_ptr->ledge_moby == candidate_moby) { return 1; } diff --git a/src/overlays/shared/mobys/update_moby_proximity_interaction.c b/src/overlays/shared/mobys/update_moby_proximity_interaction.c index cf5b531699..21126d4aab 100644 --- a/src/overlays/shared/mobys/update_moby_proximity_interaction.c +++ b/src/overlays/shared/mobys/update_moby_proximity_interaction.c @@ -87,7 +87,8 @@ void update_moby_proximity_interaction(unsigned char *moby) { if (*(short *)(proximity_state_data + 0xC) != 0) { int help_message_accepted = try_set_help_message(2, 0x53E4) != 0; if ((pad_pressed_words[0] & 0x10) && help_message_accepted) { - if (current_level_index == 10 && hero.vehicle_mode == HERO_VEHICLE_MODE_CLANK) { + if (current_level_index == LEVEL_ORXON && + hero.vehicle_mode == HERO_VEHICLE_MODE_CLANK) { MOBY(moby)->state = PROXIMITY_MOBY_STATE_FOLLOWUP_SCENES; MOBY(moby)->flags |= 0x41; start_scene(9); diff --git a/src/overlays/shared/pickups/codebot.c b/src/overlays/shared/pickups/codebot.c index 4222fe82e0..90852c3d06 100644 --- a/src/overlays/shared/pickups/codebot.c +++ b/src/overlays/shared/pickups/codebot.c @@ -52,7 +52,7 @@ void codebot_update(struct Moby *moby) { CODEBOT_REMOVE = 3 }; unsigned char *collection_flags; - if (current_level_index != 0xF) { + if (current_level_index != LEVEL_QUARTU) { moby->rot.z = fast_add_rotations(moby->rot.z, frame_time * 1.5707964f); moby->scale = moby->pclass->scale * D_L15_001621A0; switch (moby->state) { diff --git a/src/overlays/shared/props/energy_sphere_holder.c b/src/overlays/shared/props/energy_sphere_holder.c index 4d2d1a01b6..5e4359ccd7 100644 --- a/src/overlays/shared/props/energy_sphere_holder.c +++ b/src/overlays/shared/props/energy_sphere_holder.c @@ -80,7 +80,7 @@ void energy_sphere_holder_update(char *holder_moby) { (char *)D_0014C190_257218) >> (MOBY(holder_moby)->save_id & 0x1F) & 1) && - (current_level_index != 10 || + (current_level_index != LEVEL_ORXON || (visited_table = (unsigned char *)((char *)visited52), (visited_table + ((unsigned char *)holder_moby)[0xB0]))[0xA0] == 0xFF)) { MOBY(holder_moby)->state = ENERGY_SPHERE_HOLDER_COMPLETED; diff --git a/src/overlays/shared/props/red_orb.c b/src/overlays/shared/props/red_orb.c index f1dd0299ad..9b087c15d9 100644 --- a/src/overlays/shared/props/red_orb.c +++ b/src/overlays/shared/props/red_orb.c @@ -48,7 +48,7 @@ void draw_red_orb_group_effect_quads(struct Moby *reference_moby) __asm__("FUN_L void draw_red_orb_group_effect_quads(struct Moby *reference_moby) { u8 *it[2] __attribute__((aligned(16))); f32 quad_scale = 1.2f; - if (current_level_index == 0 || current_level_index == 0x12) { + if (current_level_index == LEVEL_VELDIN1 || current_level_index == LEVEL_VELDIN2) { quad_scale = 1.0f; } get_first_moby_in_group(it, reference_moby->group, 0, 0); @@ -115,7 +115,7 @@ void red_orb_update(struct Moby *moby) { g = (tweened_color >> 8) & 0xFF; r = tweened_color & 0xFF; hi = 0x38; - if (current_level_index == 0 || current_level_index == 0x12) + if (current_level_index == LEVEL_VELDIN1 || current_level_index == LEVEL_VELDIN2) hi = 0x20; packed_color_without_red = hi << 24 | b << 16; packed_color_without_red |= g << 8; diff --git a/src/overlays/shared/props/thruster_pack_lock.c b/src/overlays/shared/props/thruster_pack_lock.c index 46bdfa1ff6..1b174ceb4f 100644 --- a/src/overlays/shared/props/thruster_pack_lock.c +++ b/src/overlays/shared/props/thruster_pack_lock.c @@ -129,7 +129,7 @@ void thruster_pack_lock_update(Lock *moby) { if (((void *)((Hero *)(D_0013F350_r))->ground_moby) == moby && item_available[3] != 0 && ((Hero *)(D_0013F350_r))->air_frames.s == 0 && ((Hero *)(D_0013F350_r))->state.current == 0x22) { - if (current_level_index == 0xB && moby->activation_group != 0xFF) { + if (current_level_index == LEVEL_POKITARU && moby->activation_group != 0xFF) { int group; int group_index; l11_thruster_pack_lock_activation_state.collected[(short)moby->uid] = @@ -773,7 +773,7 @@ void update_moby_hit_stats_and_state(char *moby) { } *(int *)(collection_stats_base + 0x157EC) = *(int *)(collection_stats_base + 0x157EC) | (1 << current_level_index) | 0x80000000; - if (current_level_index == 0xB && *(char **)(hit_record + 0x20) != 0 && + if (current_level_index == LEVEL_POKITARU && *(char **)(hit_record + 0x20) != 0 && *(short *)(*(char **)(hit_record + 0x20) + 0xA6) == 0xAC) { if (++level_11_class_ac_hit_count >= 3 && item_unlocked[0x12] == 0) { item_unlocked[0x12] = 1; diff --git a/src/overlays/shared/props/trespasser_pad.c b/src/overlays/shared/props/trespasser_pad.c index 5aa3299127..b58f3967c7 100644 --- a/src/overlays/shared/props/trespasser_pad.c +++ b/src/overlays/shared/props/trespasser_pad.c @@ -3,6 +3,7 @@ #include "types.h" #include "rnc/input/pad_state.h" #include "rnc/overlay/shared/camera/level_camera.h" +#include "rnc/camera/update_cam.h" #include "rnc/mobys/moby.h" #include "rnc/hero/hero.h" #include "rnc/globals.h" @@ -339,7 +340,7 @@ void tresspasser_pad_update(Moby *moby) { set_camera_rotation(&camera_rot); D_L02_0017EB08_lui = 1; force_help_message(6, 0); - if (l02_camera.unk180 != 0 && l02_camera.unk180->unk86 != 5) { + if (l02_camera.current_camera != 0 && l02_camera.current_camera->unk86 != 5) { jet_mount(&l02_camera.pos, &l02_camera.unk150, 1, 0, 0); } i = 0; diff --git a/src/overlays/shared/rendering/debug/update_debug_menu.c b/src/overlays/shared/rendering/debug/update_debug_menu.c index 429a13c152..5711c57622 100644 --- a/src/overlays/shared/rendering/debug/update_debug_menu.c +++ b/src/overlays/shared/rendering/debug/update_debug_menu.c @@ -214,7 +214,7 @@ void update_debug_camera(void) { if ((pad->buttons.held_pressed & 3) != 3) { if (controller_words.buttons.w.held & 0x1000) { if (free_look) { - fast_vec_normalize(&step, l00_camera.unk350, g_debug_menu.movement_speed); + fast_vec_normalize(&step, l00_camera.rows, g_debug_menu.movement_speed); fast_vec_add(l00_camera.pos.f, l00_camera.pos.f, &step); } else { l00_camera.pos.f[0] += fast_cos(l00_camera.yaw) * g_debug_menu.movement_speed; @@ -224,7 +224,7 @@ void update_debug_camera(void) { } if (controller_words.buttons.w.held & 0x4000) { if (free_look) { - fast_vec_normalize(&step, l00_camera.unk350, g_debug_menu.movement_speed); + fast_vec_normalize(&step, l00_camera.rows, g_debug_menu.movement_speed); fast_vec_sub(l00_camera.pos.f, l00_camera.pos.f, &step); } else { l00_camera.pos.f[0] -= fast_cos(l00_camera.yaw) * g_debug_menu.movement_speed; @@ -234,7 +234,7 @@ void update_debug_camera(void) { } if (controller_words.buttons.w.held & 1) { if (free_look) { - fast_vec_normalize(&step, l00_camera.unk350 + 4, g_debug_menu.movement_speed); + fast_vec_normalize(&step, l00_camera.rows + 4, g_debug_menu.movement_speed); fast_vec_add(l00_camera.pos.f, l00_camera.pos.f, &step); } else { l00_camera.pos.f[0] -= fast_sin(l00_camera.yaw) * g_debug_menu.movement_speed; @@ -244,7 +244,7 @@ void update_debug_camera(void) { } if (controller_words.buttons.w.held & 2) { if (free_look) { - fast_vec_normalize(&step, l00_camera.unk350 + 4, g_debug_menu.movement_speed); + fast_vec_normalize(&step, l00_camera.rows + 4, g_debug_menu.movement_speed); fast_vec_sub(l00_camera.pos.f, l00_camera.pos.f, &step); } else { l00_camera.pos.f[0] += fast_sin(l00_camera.yaw) * g_debug_menu.movement_speed; @@ -283,9 +283,9 @@ void update_debug_camera(void) { r[1].f[0] = sine; r[0].f[0] = cosine; r[1].f[1] = cosine; - copy_matrix_rotation(m, l00_camera.unk350); + copy_matrix_rotation(m, l00_camera.rows); multiply_matrix(m, m, r); - copy_matrix3x4(l00_camera.unk350, m); + copy_matrix3x4(l00_camera.rows, m); } else { l00_camera.yaw = fast_subtract_rotations(l00_camera.yaw, g_debug_menu.yaw_speed); } @@ -315,9 +315,9 @@ void update_debug_camera(void) { r[0].f[2] = sine; r[2].f[0] = -sine; r[2].f[2] = cosine; - copy_matrix_rotation(m, l00_camera.unk350); + copy_matrix_rotation(m, l00_camera.rows); multiply_matrix(m, m, r); - copy_matrix3x4(l00_camera.unk350, m); + copy_matrix3x4(l00_camera.rows, m); } else { l00_camera.pitch = fast_subtract_rotations(l00_camera.pitch, g_debug_menu.pitch_speed); } @@ -348,9 +348,9 @@ void update_debug_camera(void) { r[1].f[2] = -sine; r[2].f[1] = sine; r[2].f[2] = cosine; - copy_matrix_rotation(m, l00_camera.unk350); + copy_matrix_rotation(m, l00_camera.rows); multiply_matrix(rolled_basis, m, r); - copy_matrix3x4(l00_camera.unk350, rolled_basis); + copy_matrix3x4(l00_camera.rows, rolled_basis); } } else { g_debug_menu.roll_speed = g_debug_menu.roll_speed / 1.5f; @@ -376,7 +376,7 @@ void update_debug_camera(void) { { Vec4 r[3]; if (free_look) { - fast_vec_normalize(&r[0], l00_camera.unk350 + 8, g_debug_menu.vertical_speed); + fast_vec_normalize(&r[0], l00_camera.rows + 8, g_debug_menu.vertical_speed); fast_vec_add(l00_camera.pos.f, l00_camera.pos.f, &r[0]); } else { l00_camera.pos.f[2] += g_debug_menu.vertical_speed; @@ -386,19 +386,19 @@ void update_debug_camera(void) { fast_vec_normalize(&r[0], &r[0], 1.0f); fast_vec_normalize(&r[1], &r[1], 1.0f); fast_vec_normalize(&r[2], &r[2], 1.0f); - copy_matrix3x4(l00_camera.unk350, r); + copy_matrix3x4(l00_camera.rows, r); } } if (g_debug_menu.control_mode == DEBUG_CONTROL_MODE_CAPTURE_HERO_CAMERA_OFFSET && - l00_camera.unk180 != 0) { - target = (DebugCameraTarget *)l00_camera.unk180; + l00_camera.current_camera != 0) { + target = (DebugCameraTarget *)l00_camera.current_camera; qcopy(target->position, l00_camera.pos.f); - qcopy(target->basis, l00_camera.unk350); - qcopy(target->basis + 4, l00_camera.unk350 + 4); - qcopy(target->basis + 8, l00_camera.unk350 + 8); - qcopy(target->previous_basis, l00_camera.unk350); + qcopy(target->basis, l00_camera.rows); + qcopy(target->basis + 4, l00_camera.rows + 4); + qcopy(target->basis + 8, l00_camera.rows + 8); + qcopy(target->previous_basis, l00_camera.rows); copy_vector3(target->camera_position, l00_camera.pos.f); - reset_follow_camera_state_from_position(l00_camera.unk180); + reset_follow_camera_state_from_position(l00_camera.current_camera); } } diff --git a/src/overlays/shared/rendering/effects/ground_particle_scatter.c b/src/overlays/shared/rendering/effects/ground_particle_scatter.c index 44b8bf6447..b5a89d2e2a 100644 --- a/src/overlays/shared/rendering/effects/ground_particle_scatter.c +++ b/src/overlays/shared/rendering/effects/ground_particle_scatter.c @@ -130,7 +130,7 @@ void ground_particle_scatter_update(Moby *moby) { float w; float zero; - if (current_level_index == 0xC || current_level_index == 0x200) { + if (current_level_index == LEVEL_HOVEN || current_level_index == 0x200) { flag = 1; } else { flag = 0; diff --git a/src/overlays/shared/rendering/effects/particles.c b/src/overlays/shared/rendering/effects/particles.c index 3785ce9c42..e815669a65 100644 --- a/src/overlays/shared/rendering/effects/particles.c +++ b/src/overlays/shared/rendering/effects/particles.c @@ -1372,7 +1372,7 @@ void update_gravity_floor_burst_particle(struct EmberParticle *ember_particle) { ember_particle->tex, ember_particle->blend); } - if (current_level_index == 10) { + if (current_level_index == LEVEL_ORXON) { if (!random_integer_below(0x13)) { emitted_position.q = ember_particle->pos.q; emitted_position.f[2] += 0.1f; diff --git a/src/overlays/shared/rendering/sky/render_sky_shells.c b/src/overlays/shared/rendering/sky/render_sky_shells.c index 126a2466ee..3092aaa819 100644 --- a/src/overlays/shared/rendering/sky/render_sky_shells.c +++ b/src/overlays/shared/rendering/sky/render_sky_shells.c @@ -13,7 +13,7 @@ void render_sky_shells(void) __asm__("FUN_L01_00252570"); void render_sky_shells(void) { setup_sky_gif_paging(); - if (current_level_index == 1) { + if (current_level_index == LEVEL_NOVALIS) { update_sky_shells_animated(); } else { update_sky_shells_static(); diff --git a/src/overlays/shared/ui/hud/initialize_hud_element_defaults.c b/src/overlays/shared/ui/hud/initialize_hud_element_defaults.c index 4b600f1053..d8e6504cc3 100644 --- a/src/overlays/shared/ui/hud/initialize_hud_element_defaults.c +++ b/src/overlays/shared/ui/hud/initialize_hud_element_defaults.c @@ -132,7 +132,7 @@ int draw_hud_progress_and_rank(HudElem *hud_element) { x -= measure_text_width_regular(formatted_hud_text, -1); print_text_with_texture_3(x + 1, y + 1, 0x80000000, formatted_hud_text, -1); print_text_with_texture_3(x, y, D_L05_0015F998, formatted_hud_text, -1); - if (current_level_index == 0x10) { + if (current_level_index == LEVEL_KALEBO3) { int y2, x2; sprintf(small_buf, D_L05_0015F860, hero.race_ammo); /* Fakematch: the dead early copy of the default row gives retail's register order. */ diff --git a/src/overlays/shared/ui/map/reveal_map_around_position.c b/src/overlays/shared/ui/map/reveal_map_around_position.c index 31dbbb785a..959c2a0c55 100644 --- a/src/overlays/shared/ui/map/reveal_map_around_position.c +++ b/src/overlays/shared/ui/map/reveal_map_around_position.c @@ -98,12 +98,12 @@ void reveal_map_around_position(f32 *position) { level = 0; } state = FALSE; - if (hero.state.control_mode == 17 || hero.state.control_mode == 18 || - hero.base_condition == 1) { + if (hero.state.control_mode == HERO_MODE_SWIM || + hero.state.control_mode == HERO_MODE_WATER_SURFACE || hero.base_condition == 1) { state = TRUE; } mode16 = hero.state.control_mode == 16; - mode15 = hero.state.control_mode == 15; + mode15 = hero.state.control_mode == HERO_MODE_GRIND; y_min = y - 16; for (i = 0, filter = filters; i < 16; i++, filter++) { diff --git a/src/overlays/shared/ui/text/level_draw_dialog_text.c b/src/overlays/shared/ui/text/level_draw_dialog_text.c index 8581c8d29c..5f3aef1cb6 100644 --- a/src/overlays/shared/ui/text/level_draw_dialog_text.c +++ b/src/overlays/shared/ui/text/level_draw_dialog_text.c @@ -175,8 +175,8 @@ void level_draw_dialog_text(void) { left = 0; mid = 0; right = 0; - switch (mode_freeze_state) { - case 6: + switch (save_card_state) { + case CS_PROMPT_FORMAT: left = 0x524F; right = 0x524B; text = get_help_message_text(0x4FAF); @@ -200,15 +200,15 @@ void level_draw_dialog_text(void) { case FREEZE_DIALOG_SHARED_PLAIN_BODY_ONLY: text = get_help_message_text(0x4FB7); break; - case 14: - case 15: + case CS_CREATE_SAVE_PENDING: + case CS_CREATING_SAVE: text = get_help_message_text(0x4FB8); break; case FREEZE_DIALOG_PLAIN_BODY_CENTERED_BUTTON: mid = 0x524A; text = get_help_message_text(0x4FBA); break; - case 18: + case CS_CREATE_FAILED: mid = 0x524A; text = get_help_message_text(0x4FBC); break; @@ -238,11 +238,11 @@ void level_draw_dialog_text(void) { text = get_help_message_text(0x4FA9); } break; - case 21: + case CS_SAVE_FAILED: mid = 0x524A; text = get_help_message_text(0x4FBD); break; - case 20: + case CS_LOAD_FAILED: mid = 0x524A; text = get_help_message_text(0x4FBB); break; diff --git a/src/overlays/shared/vehicles/background_ship_1.c b/src/overlays/shared/vehicles/background_ship_1.c index e6478bc74e..24f77aaa0c 100644 --- a/src/overlays/shared/vehicles/background_ship_1.c +++ b/src/overlays/shared/vehicles/background_ship_1.c @@ -243,7 +243,7 @@ void background_ship_1_update(char *moby) { if ((float)*(int *)path < moby_data->path_progress) { moby_data->path_progress = moby_data->path_progress - (float)*(int *)path; } - if (current_level_index == 9) { + if (current_level_index == LEVEL_GASPAR) { sample_camera_path((int *)path, 1, &MOBY(moby)->pos, @@ -276,7 +276,7 @@ void background_ship_1_update(char *moby) { } break; case BACKGROUND_SHIP_1_REMOVE: - if (current_level_index == 2) { + if (current_level_index == LEVEL_ARIDIA) { level_2_ship_removal_count = level_2_ship_removal_count + 1; if (level_2_ship_removal_count >= 3) { unsigned char *p = item_unlocked; @@ -287,7 +287,7 @@ void background_ship_1_update(char *moby) { } } } - if (current_level_index == 9) { + if (current_level_index == LEVEL_GASPAR) { if (*(int *)(camera_secondary_mode) == 0x32) { level_9_ship_removal_count = level_9_ship_removal_count + 1; if (level_9_ship_removal_count >= 5) { diff --git a/src/overlays/shared/vehicles/background_ship_2.c b/src/overlays/shared/vehicles/background_ship_2.c index ca28275e95..15d3aca22b 100644 --- a/src/overlays/shared/vehicles/background_ship_2.c +++ b/src/overlays/shared/vehicles/background_ship_2.c @@ -231,7 +231,7 @@ void background_ship_2_update(char *moby) { int invalid_index; MOBY(moby)->update_dist = 0xFF; MOBY(moby)->draw_dist = 0xFF; - if (current_level_index == 10) { + if (current_level_index == LEVEL_ORXON) { MOBY(moby)->scale = MOBY(moby)->scale * 0.5f; } invalid_index = -1; @@ -259,7 +259,7 @@ void background_ship_2_update(char *moby) { break; } case BACKGROUND_SHIP_2_FOLLOW_PATH: - if (*(unsigned char *)D_001413F4 == 1 && current_level_index == 10) { + if (*(unsigned char *)D_001413F4 == 1 && current_level_index == LEVEL_ORXON) { mark_moby_for_removal(moby); return; } @@ -268,7 +268,7 @@ void background_ship_2_update(char *moby) { moby_data->unk6C = allocate_voice_for_target_entry(1, 4, (int)moby); } path_travel_distance = background_ship_2_path_travel_speed_gp * frame_time; - if (current_level_index == 10) { + if (current_level_index == LEVEL_ORXON) { path_travel_distance = path_travel_distance * 0.25f; } moby_data->path_progress = @@ -299,7 +299,7 @@ void background_ship_2_update(char *moby) { MOBY(moby)->collision = *(int *)(((char *)MOBY(moby)->pclass) + 0x10); } if (MOBY(moby)->visible != 0) { - if (current_level_index != 10) { + if (current_level_index != LEVEL_ORXON) { spawn_background_ship_2_joint_sparks(moby, tv); } else { spawn_background_ship_2_level_10_joint_sparks(moby, tv); @@ -313,7 +313,7 @@ void background_ship_2_update(char *moby) { } break; case BACKGROUND_SHIP_2_REMOVE: - if (current_level_index == 2) { + if (current_level_index == LEVEL_ARIDIA) { level_2_ship_removal_count = level_2_ship_removal_count + 1; if (level_2_ship_removal_count >= 3) { unsigned char *p = item_unlocked; @@ -324,7 +324,7 @@ void background_ship_2_update(char *moby) { } } } - if (current_level_index == 9) { + if (current_level_index == LEVEL_GASPAR) { if (*(int *)camera_secondary_mode == 0x32) { level_9_ship_removal_count = level_9_ship_removal_count + 1; if (level_9_ship_removal_count >= 5) { diff --git a/src/overlays/shared/vehicles/giant_clank_pad.c b/src/overlays/shared/vehicles/giant_clank_pad.c index 035eba9a61..bddbfcca99 100644 --- a/src/overlays/shared/vehicles/giant_clank_pad.c +++ b/src/overlays/shared/vehicles/giant_clank_pad.c @@ -69,14 +69,15 @@ void giant_clank_pad_update(struct Moby *moby) { if (hero.vehicle_mode == HERO_VEHICLE_MODE_ON_FOOT) { try_set_help_message(4, 0x3aa4); } else if (hero.vehicle_mode == HERO_VEHICLE_MODE_GIANT_CLANK && - current_level_index != 0x12) { + current_level_index != LEVEL_VELDIN2) { try_set_help_message(4, 0x3aa5); } if (!(((u32)pad_pressed_lui) & 0x10)) return; if (D_L15_0015F594 != 4) return; - if (hero.vehicle_mode == HERO_VEHICLE_MODE_GIANT_CLANK && current_level_index == 0xf) { + if (hero.vehicle_mode == HERO_VEHICLE_MODE_GIANT_CLANK && + current_level_index == LEVEL_QUARTU) { pad = l15_moby_array; pad += *(int *)((u8 *)linked + 0x60); pad->flags |= 1; @@ -84,7 +85,7 @@ void giant_clank_pad_update(struct Moby *moby) { pad->visible = 0; restore_saved_hero_moby_and_clear_vehicle_mode(); set_moby_animation(pad, 0, 0); - if (current_level_index != 0xf) + if (current_level_index != LEVEL_QUARTU) return; start_scene(9); request_music_track(0, 5); @@ -101,14 +102,14 @@ void giant_clank_pad_update(struct Moby *moby) { pad->visible = 1; pad->flags &= ~1; enter_hero_vehicle_mode(2, 0x5a, pad); - if (current_level_index == 0xf) { + if (current_level_index == LEVEL_QUARTU) { start_scene(8); *(u128 *)hero.saved_pos_rot = *(u128 *)&hero.motion.pos; *(u128 *)(hero.saved_pos_rot + 16) = *(u128 *)&hero.motion.rot; request_music_track(2, 4); return; } - if (current_level_index != 0x12) + if (current_level_index != LEVEL_VELDIN2) return; start_scene(6); *(u128 *)hero.saved_pos_rot = *(u128 *)&hero.motion.pos; diff --git a/src/overlays/shared/vendor/draw_vendor_inset_quads.c b/src/overlays/shared/vendor/draw_vendor_inset_quads.c index 1dac901871..9294156f27 100644 --- a/src/overlays/shared/vendor/draw_vendor_inset_quads.c +++ b/src/overlays/shared/vendor/draw_vendor_inset_quads.c @@ -370,10 +370,10 @@ void draw_vendor_screen(void) { } qzero(camera_lateral_axis); qzero(D_L00_00166FF0); - l00_camera.unk350[0] = 1.0f; - l00_camera.unk350[5] = 1.0f; - l00_camera.unk350[10] = 1.0f; - l00_camera.unk350[11] = 1.0f; + l00_camera.rows[0] = 1.0f; + l00_camera.rows[5] = 1.0f; + l00_camera.rows[10] = 1.0f; + l00_camera.rows[11] = 1.0f; update_camera_view_matrices(); } else { D_L00_00165F80[0] = D_L00_00166FD0[0]; diff --git a/src/overlays/shared/vendor/vendor.c b/src/overlays/shared/vendor/vendor.c index 03cc51e4e9..a43abfd374 100644 --- a/src/overlays/shared/vendor/vendor.c +++ b/src/overlays/shared/vendor/vendor.c @@ -379,8 +379,8 @@ void vendor_update(P_2a57a8 *vendor_moby) { q->auxiliary_moby->auxiliary_scale = q->effect_scale_factor * q->auxiliary_moby->p24->auxiliary_scale_multiplier * 2.5f; update_entity(q->auxiliary_moby); - if (hero.state.control_mode != 0 && hero.state.current != 3 && - hero.state.control_mode != 1) { + if (hero.state.control_mode != HERO_MODE_IDLE && hero.state.current != 3 && + hero.state.control_mode != HERO_MODE_RUN) { interaction_allowed = 0; help_message_allowed = 0; } diff --git a/src/overlays/shared/vendor/vendor_menu.c b/src/overlays/shared/vendor/vendor_menu.c index e91e05d1a3..0e80d9aa89 100644 --- a/src/overlays/shared/vendor/vendor_menu.c +++ b/src/overlays/shared/vendor/vendor_menu.c @@ -1582,15 +1582,15 @@ void update_vendor_menu(void) { sce_vu0_rot_matrix_x(camera_rotation_matrix, camera_rotation_matrix, rot[0]); sce_vu0_rot_matrix_y(camera_rotation_matrix, camera_rotation_matrix, rot[1]); sceVu0RotMatrixZ(camera_rotation_matrix, camera_rotation_matrix, camera_world_z_rotation); - l00_camera.unk350[0] = -camera_rotation_matrix[2][0]; - l00_camera.unk350[4] = -camera_rotation_matrix[0][0]; - l00_camera.unk350[8] = camera_rotation_matrix[1][0]; - l00_camera.unk350[1] = -camera_rotation_matrix[2][1]; - l00_camera.unk350[5] = -camera_rotation_matrix[0][1]; - l00_camera.unk350[9] = camera_rotation_matrix[1][1]; - l00_camera.unk350[2] = -camera_rotation_matrix[2][2]; - l00_camera.unk350[6] = -camera_rotation_matrix[0][2]; - l00_camera.unk350[10] = camera_rotation_matrix[1][2]; + l00_camera.rows[0] = -camera_rotation_matrix[2][0]; + l00_camera.rows[4] = -camera_rotation_matrix[0][0]; + l00_camera.rows[8] = camera_rotation_matrix[1][0]; + l00_camera.rows[1] = -camera_rotation_matrix[2][1]; + l00_camera.rows[5] = -camera_rotation_matrix[0][1]; + l00_camera.rows[9] = camera_rotation_matrix[1][1]; + l00_camera.rows[2] = -camera_rotation_matrix[2][2]; + l00_camera.rows[6] = -camera_rotation_matrix[0][2]; + l00_camera.rows[10] = camera_rotation_matrix[1][2]; for (i = 0; i < D_L00_0016C860.h44; i++) { mb = D_L00_0016C860.f178[i]; id = D_L00_0016C860.f38 >> 1; diff --git a/src/overlays/shared/weapons/bomb_glove_bomb.c b/src/overlays/shared/weapons/bomb_glove_bomb.c index e7712f5e3f..2f1b69c76a 100644 --- a/src/overlays/shared/weapons/bomb_glove_bomb.c +++ b/src/overlays/shared/weapons/bomb_glove_bomb.c @@ -867,7 +867,7 @@ void launch_bomb(float *pos, unsigned char *moby, float *velocity) { *(short *)((char *)bomb_launch_data + 0x6a) = scale_game_frames(30); moby[0x20] = 1; qcopy(bomb_launch_data, velocity); - if (hero.state.control_mode == 15) { + if (hero.state.control_mode == HERO_MODE_GRIND) { fast_vec_add(bomb_launch_data, bomb_launch_data, &hero.motion.displacement); } else if (hero.ground_moby != 0 && FUN_002141f8_cf((unsigned char *)hero.ground_moby) != 0) { fast_vec_add(bomb_launch_data, bomb_launch_data, &hero.motion.displacement); @@ -965,7 +965,7 @@ int predict_throw_landing(LandingVars *v, M910 *thrown_moby, int mode) { fast_vec_add(&position, &position, &hero.motion.pos); position.f[2] += 0.49082f; qcopy(&velocity, &v->vel); - if (hero.state.control_mode == 15) + if (hero.state.control_mode == HERO_MODE_GRIND) fast_vec_add(&velocity, &velocity, &hero.motion.displacement); if (hero.ground_moby && FUN_L00_002603d0_2ad410((M910 *)hero.ground_moby) && mode) fast_vec_add(&velocity, &velocity, &hero.motion.displacement); diff --git a/src/overlays/shared/weapons/decoy.c b/src/overlays/shared/weapons/decoy.c index 4d7b962998..b2d9e8256a 100644 --- a/src/overlays/shared/weapons/decoy.c +++ b/src/overlays/shared/weapons/decoy.c @@ -386,7 +386,7 @@ s32 predict_thrown_moby_landing(ThrowVars *throw_vars, struct Moby *thrown_moby, fast_vec_add(&predicted_position, &predicted_position, &hero.motion.pos); predicted_position.f[2] += 0.39081999659538269043f; qcopy(&predicted_velocity, &throw_vars->vel); - if (hero.state.control_mode == 15) + if (hero.state.control_mode == HERO_MODE_GRIND) fast_vec_add(&predicted_velocity, &predicted_velocity, &hero.motion.displacement); if (hero.ground_moby && FUN_L00_002603d0((int)hero.ground_moby) && mode) fast_vec_add(&predicted_velocity, &predicted_velocity, &hero.motion.displacement); diff --git a/src/overlays/shared/weapons/devastator.c b/src/overlays/shared/weapons/devastator.c index d037627b21..5d31143e22 100644 --- a/src/overlays/shared/weapons/devastator.c +++ b/src/overlays/shared/weapons/devastator.c @@ -561,7 +561,7 @@ void devastator_update(struct Moby *devastator_moby) { yaw0, pitch0); } - if (hero.state.control_mode == 0 || + if (hero.state.control_mode == HERO_MODE_IDLE || (hero.state.current == 2 && hero.stick_magnitude < 0.7f)) { set_hero_animation(0x36, 1, (float)scale_game_frames(10)); } else { diff --git a/src/overlays/shared/weapons/glove_of_doom_bomb.c b/src/overlays/shared/weapons/glove_of_doom_bomb.c index 3d26884163..17c4db3ff1 100644 --- a/src/overlays/shared/weapons/glove_of_doom_bomb.c +++ b/src/overlays/shared/weapons/glove_of_doom_bomb.c @@ -98,7 +98,7 @@ s32 predict_doom_bot_spawner_landing(ThrowVars *throw_vars, struct Moby *thrown_ add_vector_xyz_2c8440(&simulated_position, &simulated_position, &hero.motion.pos); simulated_position.f[2] += 0.39081999659538269043f; qcopy(&simulated_velocity, &throw_vars->vel); - if (hero.state.control_mode == 15) + if (hero.state.control_mode == HERO_MODE_GRIND) add_vector_xyz_2c8440( &simulated_velocity, &simulated_velocity, &hero.motion.displacement); if (hero.ground_moby && get_moby_pvars_link((int)hero.ground_moby) && mode) diff --git a/src/overlays/shared/weapons/morphoray.c b/src/overlays/shared/weapons/morphoray.c index 5ab307b6ab..692456a992 100644 --- a/src/overlays/shared/weapons/morphoray.c +++ b/src/overlays/shared/weapons/morphoray.c @@ -1536,9 +1536,9 @@ void morphoray_update(Moby *moby) { } func_001F9938_2BDAF0(&morphoray_state->timer); if ((((unsigned int)((Hero *)((char *)&hero))->state.control_mode < 2 || - ((Hero *)((char *)&hero))->state.control_mode == 12 || - ((Hero *)((char *)&hero))->state.control_mode == 4 || - ((Hero *)((char *)&hero))->state.control_mode == 5)) && + ((Hero *)((char *)&hero))->state.control_mode == HERO_MODE_CROUCH || + ((Hero *)((char *)&hero))->state.control_mode == HERO_MODE_JUMP || + ((Hero *)((char *)&hero))->state.control_mode == HERO_MODE_LAND)) && (pad_held_words[0] & ((Hero *)((char *)&hero))->items[0].button_mask) != 0 && !busy && in_range) { if (((Hero *)((char *)&hero))->item_anim_active == 0) { @@ -1625,7 +1625,7 @@ void morphoray_update(Moby *moby) { morphoray_state->total); } if (morphoray_state->target != 0 && morphoray_state->left <= 0.0f) { - if (current_level_index == 5 && morphoray_state->target->oclass == 0x271 && + if (current_level_index == LEVEL_RILGAR && morphoray_state->target->oclass == 0x271 && item_unlocked[8] == 0) { item_unlocked[8] = 1; allocate_voice_for_bank_entry(1, 0, 0); diff --git a/src/overlays/shared/weapons/pyrocitor.c b/src/overlays/shared/weapons/pyrocitor.c index 977409751a..b0bba44390 100644 --- a/src/overlays/shared/weapons/pyrocitor.c +++ b/src/overlays/shared/weapons/pyrocitor.c @@ -622,11 +622,11 @@ void pyrocitor_update(struct Moby *moby) { else gate = 0; if (hero.state.current == 1 && (moby->flags & 1)) { - fast_vec_normalize(&light_color_and_flame_origin, &l00_camera.unk350[8], -1.0f); + fast_vec_normalize(&light_color_and_flame_origin, &l00_camera.rows[8], -1.0f); fast_vec_add( &light_color_and_flame_origin, &light_color_and_flame_origin, &l00_camera.pos); fast_vec_normalize(&light_offset_and_flame_velocity, - l00_camera.unk350, + l00_camera.rows, pyrocitor_flame_base_range_gp + speed + 0.75f); fast_vec_add( &endpoint, &light_offset_and_flame_velocity, &light_color_and_flame_origin); diff --git a/src/overlays/shared/weapons/suckcannon.c b/src/overlays/shared/weapons/suckcannon.c index 0431964ff6..412440d217 100644 --- a/src/overlays/shared/weapons/suckcannon.c +++ b/src/overlays/shared/weapons/suckcannon.c @@ -1295,7 +1295,7 @@ void compute_suck_cannon_suction_aim_and_origin(struct Moby *cannon_moby, suction_origin_offset.z = 0; *out_suction_pitch = -suction_aim_camera->pitch; transform_vector_by_basis( - &suction_origin_offset, &suction_origin_offset, suction_aim_camera->unk350); + &suction_origin_offset, &suction_origin_offset, suction_aim_camera->rows); out_suction_origin[2] = suction_origin_offset.z + cannon_moby->pos.z; out_suction_origin[0] = suction_origin_offset.x + hero.motion.pos.f[0]; out_suction_origin[1] = suction_origin_offset.y + hero.motion.pos.f[1]; diff --git a/src/overlays/shared/weapons/swingshot.c b/src/overlays/shared/weapons/swingshot.c index c0e7ba0997..25650de884 100644 --- a/src/overlays/shared/weapons/swingshot.c +++ b/src/overlays/shared/weapons/swingshot.c @@ -238,7 +238,8 @@ void swingshot_update(Moby *m) { *(u128 *)&h->rot_row2 = *(u128 *)&m->rot_row2; } } - if (hero.state.current == 0x24 || (hero.state.control_mode == 0xF && hero.unk5B4)) { + if (hero.state.current == 0x24 || + (hero.state.control_mode == HERO_MODE_GRIND && hero.unk5B4)) { if (hd) { d->size = 0.280000001f; d->scale = 1.0f; @@ -273,9 +274,10 @@ void swingshot_update(Moby *m) { } FUN_001f9a28_2bffa8(&v0, &hero.grapple_target->pos, &d->hook->pos); speed = hd->speed; - if (hero.state.control_mode == 0xF) { + if (hero.state.control_mode == HERO_MODE_GRIND) { speed = speed + hero.unk574; - } else if (hero.state.prev_control_mode == 4 || hero.state.prev_control_mode == 2) { + } else if (hero.state.prev_control_mode == HERO_MODE_JUMP || + hero.state.prev_control_mode == HERO_MODE_FALL) { if (2.0f < hero.ground_distance) speed = frame_time * 48.0f; } @@ -551,7 +553,8 @@ child_ready:; *(u128 *)(child + 0xd0) = *(u128 *)(m + 0xd0); *(u128 *)(child + 0xe0) = *(u128 *)(m + 0xe0); } - if ((hero.state.current == 36 || (hero.state.control_mode == 15 && hero.unk5B4)) && + if ((hero.state.current == 36 || + (hero.state.control_mode == HERO_MODE_GRIND && hero.unk5B4)) && motion) { *(float *)(vars + 0x18) = 0.0f; *(float *)(vars + 0x1c) = 1.0f; @@ -586,9 +589,10 @@ child_ready:; blend_moby_animation(m, 4, 0, scale_game_frames(10)); FUN_001ff2a8_2c6158(&a, ((u8 *)hero.grapple_target) + 0x10, (*(u8 **)(vars + 0x14)) + 0x10); speed = *(float *)(motion + 4); - if (hero.state.control_mode == 15) + if (hero.state.control_mode == HERO_MODE_GRIND) speed += hero.unk574; - else if ((hero.state.prev_control_mode == 4 || hero.state.prev_control_mode == 2) && + else if ((hero.state.prev_control_mode == HERO_MODE_JUMP || + hero.state.prev_control_mode == HERO_MODE_FALL) && hero.ground_distance > 2.0f) speed = frame_time * 48.0f; qcopy(&b, &hero.motion.pos); diff --git a/src/overlays/shared/weapons/turret_rocket.c b/src/overlays/shared/weapons/turret_rocket.c index a6312d9987..dce0de2c33 100644 --- a/src/overlays/shared/weapons/turret_rocket.c +++ b/src/overlays/shared/weapons/turret_rocket.c @@ -175,7 +175,7 @@ char *spawn_turret_rocket(int firing_moby, float *position, float *rotation, int -1); } while ((float)i < moby_creation_particle_count_limit_gp); } - if (current_level_index == 12) + if (current_level_index == LEVEL_HOVEN) *(int *)(created_moby_private_state + 0x18) = scale_game_frames(120); else *(int *)(created_moby_private_state + 0x18) = diff --git a/src/overlays/shared/weapons/visibomb.c b/src/overlays/shared/weapons/visibomb.c index 5b3b848ffc..b7ce8f85e1 100644 --- a/src/overlays/shared/weapons/visibomb.c +++ b/src/overlays/shared/weapons/visibomb.c @@ -101,7 +101,7 @@ void visibomb_update(O_b3058 *visibomb_moby) { if (g->state.current == 0x72 || g->state.current == 0x65) goto tail; camera = &l00_camera; - if (camera->unk180 != 0 && *(s16 *)((u8 *)camera->unk180 + 0x86) == 5) + if (camera->current_camera != 0 && *(s16 *)((u8 *)camera->current_camera + 0x86) == 5) goto tail; if (g->grounded_frames == 0) goto tail; @@ -112,10 +112,10 @@ void visibomb_update(O_b3058 *visibomb_moby) { b = 0.0f; launch_yaw = g->held_pose_yaw; if (g->state.current == 1 && (g->moby->flags & 1)) { - launch_yaw = fast_arc_tan(camera->unk350[0], camera->unk350[1]); - b = -fast_arc_tan(vector_length_xy(camera->unk350), camera->unk350[2]); - fast_vec_normalize(launch_position, camera->unk350, 0.3f); - fast_vec_normalize(u, &camera->unk350[8], -0.35f); + launch_yaw = fast_arc_tan(camera->rows[0], camera->rows[1]); + b = -fast_arc_tan(vector_length_xy(camera->rows), camera->rows[2]); + fast_vec_normalize(launch_position, camera->rows, 0.3f); + fast_vec_normalize(u, &camera->rows[8], -0.35f); fast_vec_add(launch_position, launch_position, u); fast_vec_add(launch_position, launch_position, &camera->pos); } else if (hero.unk22C8 == 1) { diff --git a/src/overlays/shared/weapons/visibomb_missile.c b/src/overlays/shared/weapons/visibomb_missile.c index 98c0564eac..518c15fb79 100644 --- a/src/overlays/shared/weapons/visibomb_missile.c +++ b/src/overlays/shared/weapons/visibomb_missile.c @@ -849,11 +849,12 @@ void visibomb_missile_update(struct Moby *missile_moby) { force_help_message(6, 0); missile_vars->f10--; if (!(-scale_game_frames(100) < missile_vars->f10) || hero.state.current == 0x16 || - hero.state.current == 0x3D || hero.state.current == 0x72 || hero.state.control_mode == 2 || - hero.state.control_mode == 4 || hero.state.control_mode == 3 || - hero.state.control_mode > 12 || hero.state.control_mode == 7 || - hero.state.control_mode == 10 || hero.state.control_mode == 16 || - hero.state.control_mode == 5 || hero.state.current == 0x65 || hero.grounded_frames == 0 || + hero.state.current == 0x3D || hero.state.current == 0x72 || + hero.state.control_mode == HERO_MODE_FALL || hero.state.control_mode == HERO_MODE_JUMP || + hero.state.control_mode == HERO_MODE_LEDGE || hero.state.control_mode > 12 || + hero.state.control_mode == HERO_MODE_HURT || hero.state.control_mode == 10 || + hero.state.control_mode == 16 || hero.state.control_mode == HERO_MODE_LAND || + hero.state.current == 0x65 || hero.grounded_frames == 0 || (((Tgt *)hero.ground_moby) != 0 && (((Tgt *)hero.ground_moby)->hA6 == 0x13E || ((Tgt *)hero.ground_moby)->hA6 == 0x46F))) { func_L00_002B6E10_2b6140(missile_moby, missile_vars); diff --git a/src/rendering/frame/render_level_frame.c b/src/rendering/frame/render_level_frame.c index 7979041733..b0f9a9ab49 100644 --- a/src/rendering/frame/render_level_frame.c +++ b/src/rendering/frame/render_level_frame.c @@ -77,7 +77,8 @@ void render_level_frame(void) { draw_mobys(); append_dma_tag(0x02080000); setup_gif_paging(1); - if ((current_level_index != 0) && ((current_level_index != 1) || (level_available[3] != 0))) { + if ((current_level_index != LEVEL_VELDIN1) && + ((current_level_index != LEVEL_NOVALIS) || (level_available[3] != 0))) { build_resident_indexed_texture_warp_meshes(D_0018CC98[0]); } if ((level_render_state.scene_mode == 4) && (D_0018CB54[0] >= 0x3D)) { @@ -87,7 +88,8 @@ void render_level_frame(void) { } draw_resident_textured_banner(overlay_alpha); } - if ((current_level_index != 0) && ((current_level_index != 1) || (level_available[3] != 0))) { + if ((current_level_index != LEVEL_VELDIN1) && + ((current_level_index != LEVEL_NOVALIS) || (level_available[3] != 0))) { render_environment_mapped_object(D_0018CC98[0]); } if ((memory_card_state.state >= MEMCARD_REQUEST_FORMAT) || diff --git a/src/rendering/mobys/render_environment_mapped_object.c b/src/rendering/mobys/render_environment_mapped_object.c index bc33d40c4e..475d393dbd 100644 --- a/src/rendering/mobys/render_environment_mapped_object.c +++ b/src/rendering/mobys/render_environment_mapped_object.c @@ -96,8 +96,8 @@ void render_environment_mapped_object(EnvironmentMappedObject *mesh_object) { colors[0] = color; build_moby_bone_transform(mesh_object, 0, object_transform); if (game_mode != 0 || - (absolute_float(preview_camera.position.f[0] - mesh_object->position_x) < 16.0f && - absolute_float(preview_camera.position.f[1] - mesh_object->position_y) < 16.0f)) { + (absolute_float(game_camera.position.f[0] - mesh_object->position_x) < 16.0f && + absolute_float(game_camera.position.f[1] - mesh_object->position_y) < 16.0f)) { mapping_enabled = 1; } if (game_mode == 6 && ship_substate[0] == 4) { diff --git a/src/rendering/occlusion/build_occlusion_visibility.c b/src/rendering/occlusion/build_occlusion_visibility.c index c507fa856a..9d15601566 100644 --- a/src/rendering/occlusion/build_occlusion_visibility.c +++ b/src/rendering/occlusion/build_occlusion_visibility.c @@ -32,9 +32,9 @@ void build_occlusion_visibility(void) { f32 *octant_mask_data; s32 bx, by, bz; - x = truncate_float_to_s32(preview_camera.position.f[0] * scale); - y = truncate_float_to_s32(preview_camera.position.f[1] * scale); - z = truncate_float_to_s32(preview_camera.position.f[2] * scale); + x = truncate_float_to_s32(game_camera.position.f[0] * scale); + y = truncate_float_to_s32(game_camera.position.f[1] * scale); + z = truncate_float_to_s32(game_camera.position.f[2] * scale); vis = parse_occlusion_grid(x, y, z); if (vis != 0) { occl_invalid_grid = 0; @@ -49,7 +49,7 @@ void build_occlusion_visibility(void) { x + 1, y, z, - preview_camera.position.f[0] * scale - + game_camera.position.f[0] * scale - convert_integer_to_float(x)); gy = get_occlusion_grid_from_pair(x, y - 1, @@ -57,7 +57,7 @@ void build_occlusion_visibility(void) { x, y + 1, z, - preview_camera.position.f[1] * scale - + game_camera.position.f[1] * scale - convert_integer_to_float(y)); gz = get_occlusion_grid_from_pair(x, y, @@ -65,7 +65,7 @@ void build_occlusion_visibility(void) { x, y, z + 1, - preview_camera.position.f[2] * scale - + game_camera.position.f[2] * scale - convert_integer_to_float(z)); if (gx != 0 || gy != 0 || gz != 0) { fast_mem_zero16(occl_visibility_merged, 0x80); @@ -98,9 +98,9 @@ void build_occlusion_visibility(void) { case OCCLUSION_FALLBACK_OCTANT_MASK: octant_mask_data = occl_oct; if (octant_mask_data != 0) { - bx = 0.0f < preview_camera.position.f[0] - octant_mask_data[0]; - by = 0.0f < preview_camera.position.f[1] - octant_mask_data[1]; - bz = 0.0f < preview_camera.position.f[2] - octant_mask_data[2]; + bx = 0.0f < game_camera.position.f[0] - octant_mask_data[0]; + by = 0.0f < game_camera.position.f[1] - octant_mask_data[1]; + bz = 0.0f < game_camera.position.f[2] - octant_mask_data[2]; fast_mem_copy(occl_visibility, (u8 *)octant_mask_data + ((bz + by * 2 + bx * 4) * 0x80 + 0x10), 0x80); diff --git a/src/rendering/view/project_to_screen.c b/src/rendering/view/project_to_screen.c index 66ae103dd7..6d9c4706bf 100644 --- a/src/rendering/view/project_to_screen.c +++ b/src/rendering/view/project_to_screen.c @@ -36,10 +36,10 @@ void project_to_screen(struct ScreenPoint *screen_out, s32 world_pos) { f32 x; set_identity_matrix(&L); - L.v30 = -preview_camera.position.f[0] * 1024.0f; - L.v34 = -preview_camera.position.f[1] * 1024.0f; - L.v38 = -preview_camera.position.f[2] * 1024.0f; - multiply_matrix(&L.v40, (u8 *)&preview_camera + 0x40, &L); + L.v30 = -game_camera.position.f[0] * 1024.0f; + L.v34 = -game_camera.position.f[1] * 1024.0f; + L.v38 = -game_camera.position.f[2] * 1024.0f; + multiply_matrix(&L.v40, (u8 *)&game_camera + 0x40, &L); fast_vec_scale(&L.blk80, world_pos, 1024.0f); L.v8C = 1.0f; transform_vector(&L.v90, &L.blk80, &L.v40); diff --git a/src/rendering/view/reset_active_camera_position_and_basis.c b/src/rendering/view/reset_active_camera_position_and_basis.c index c34e04560a..478a117122 100644 --- a/src/rendering/view/reset_active_camera_position_and_basis.c +++ b/src/rendering/view/reset_active_camera_position_and_basis.c @@ -7,16 +7,16 @@ extern s32 D_001872B0; void reset_active_camera_position_and_basis(void) __asm__("FUN_00218d10"); void reset_active_camera_position_and_basis(void) { - preview_camera.position.f[0] = 256.0f; - preview_camera.position.f[2] = 64.0f; - preview_camera.position.f[1] = 256.0f; - qzero(&preview_camera.forward); + game_camera.position.f[0] = 256.0f; + game_camera.position.f[2] = 64.0f; + game_camera.position.f[1] = 256.0f; + qzero(&game_camera.forward); qzero(&active_camera_basis_column1_x); qzero(&D_001872B0); - preview_camera.forward.f[0] = 1.0f; - preview_camera.right.f[1] = 1.0f; - preview_camera.up.f[2] = 1.0f; - preview_camera.up.f[3] = 1.0f; + game_camera.forward.f[0] = 1.0f; + game_camera.right.f[1] = 1.0f; + game_camera.up.f[2] = 1.0f; + game_camera.up.f[3] = 1.0f; } extern __typeof__(reset_active_camera_position_and_basis) func_00218D10 diff --git a/src/rendering/view/update_camera_view_matrices.c b/src/rendering/view/update_camera_view_matrices.c index 959c4ebe75..07ca97865a 100644 --- a/src/rendering/view/update_camera_view_matrices.c +++ b/src/rendering/view/update_camera_view_matrices.c @@ -22,13 +22,13 @@ extern void scale_vector(void *, void *, f32) __asm__("FUN_001f9a80"); void update_camera_view_matrices(void) __asm__("FUN_001f2260"); void update_camera_view_matrices(void) { - Vec4 camera_basis_matrix[4]; - struct PreviewCamera *camera_view_matrices; - u8 *x; - f32 *xf; - f32 homogeneous_offset_x; - f32 homogeneous_offset_y; - f32 homogeneous_offset_z; + Vec4 camera_basis_matrix[4]; + struct GameCamera *camera_view_matrices; + u8 *x; + f32 *xf; + f32 homogeneous_offset_x; + f32 homogeneous_offset_y; + f32 homogeneous_offset_z; if (camera_position_publication_suppressed[0] == 0) { qcopy(&camera_basis_matrix[0].q, camera_rows); @@ -36,11 +36,11 @@ void update_camera_view_matrices(void) { qcopy(&camera_basis_matrix[2].q, camera_rows + 0x20); } else { sceVu0UnitMatrix(camera_basis_matrix); - SceVu0RotMatrixX(camera_basis_matrix, camera_basis_matrix, preview_camera.rotation.f[0]); - SceVu0RotMatrixY(camera_basis_matrix, camera_basis_matrix, preview_camera.rotation.f[1]); - sceVu0RotMatrixZ(camera_basis_matrix, camera_basis_matrix, preview_camera.rotation.f[2]); + SceVu0RotMatrixX(camera_basis_matrix, camera_basis_matrix, game_camera.rotation.f[0]); + SceVu0RotMatrixY(camera_basis_matrix, camera_basis_matrix, game_camera.rotation.f[1]); + sceVu0RotMatrixZ(camera_basis_matrix, camera_basis_matrix, game_camera.rotation.f[2]); } - camera_view_matrices = &preview_camera; + camera_view_matrices = &game_camera; x = D_0018CD00 + 0xC0; xf = (f32 *)D_0018CD00; camera_view_matrices->view_matrices[0] = -camera_basis_matrix[1].f[0]; diff --git a/src/sdk/graph/sce_gs_set_def_disp_env.c b/src/sdk/graph/sce_gs_set_def_disp_env.c index c67523f1ae..4d75a534b1 100644 --- a/src/sdk/graph/sce_gs_set_def_disp_env.c +++ b/src/sdk/graph/sce_gs_set_def_disp_env.c @@ -12,8 +12,8 @@ typedef struct { s32 pad08[2]; } GsVideoModeState; -extern void InvokeKernelSyscall0080( - s32 mode, s32 *horizontal, s32 *vertical, s32 *display_width, s32 *display_height); +extern void +_GetGsDxDyOffset(s32 mode, s32 *horizontal, s32 *vertical, s32 *display_width, s32 *display_height); extern char unsupported_display_mode_format[] __asm__("D_00153040"); /* The progressive arms spell this out three times: cc1 merges the divides but keeps @@ -41,7 +41,7 @@ void sceGsSetDefDispEnv(struct sceGsDispEnv *output, state = sceGsGetGParam(); if (!((u32)(state->wMode - 2) < 2) && checkModelVersion() != 0) { - InvokeKernelSyscall0080( + _GetGsDxDyOffset( (s16)state->wMode, &kernel_horizontal, &kernel_vertical, &kernel_width, &kernel_height); } else { kernel_height = 0; diff --git a/src/sdk/kernel/InitSystemCallTableAddress.c b/src/sdk/kernel/InitSystemCallTableAddress.c index 0e570b8652..248e4fb18e 100644 --- a/src/sdk/kernel/InitSystemCallTableAddress.c +++ b/src/sdk/kernel/InitSystemCallTableAddress.c @@ -16,7 +16,7 @@ struct SyscallMidTable { extern u32 D_00130308[]; extern struct SyscallMidTable syscall_table_address_init_bindings __asm__("D_00130310"); -extern s32 InvokeKernelSyscall0083_Rfu(); +extern s32 FindAddress(); extern s32 Rfu116SetSyscallMid(); extern void FindKernelAddress(); extern void KernelCopyRdata(); @@ -31,20 +31,18 @@ void InitSystemCallTableAddress(void) { syscall_table_address_init_bindings.unk4); Rfu116SetSyscallMid(syscall_table_address_init_bindings.unk8, syscall_table_address_init_bindings.unkC); - find_cursor = InvokeKernelSyscall0083_Rfu(0x80000000, 0x80080000, &FindKernelAddress); + find_cursor = FindAddress(0x80000000, 0x80080000, &FindKernelAddress); find_addr = find_cursor - 0x20C; - copy_cursor = InvokeKernelSyscall0083_Rfu(0x80000000, 0x80080000, &KernelCopyRdata); + copy_cursor = FindAddress(0x80000000, 0x80080000, &KernelCopyRdata); copy_addr = copy_cursor - 0x168; if (find_addr != copy_addr) { ; do { if ((find_addr < copy_addr) != 0) { - find_cursor = - InvokeKernelSyscall0083_Rfu(find_cursor + 4, 0x80080000, &FindKernelAddress); + find_cursor = FindAddress(find_cursor + 4, 0x80080000, &FindKernelAddress); find_addr = find_cursor - 0x20C; } else { - copy_cursor = - InvokeKernelSyscall0083_Rfu(copy_cursor + 4, 0x80080000, &KernelCopyRdata); + copy_cursor = FindAddress(copy_cursor + 4, 0x80080000, &KernelCopyRdata); copy_addr = copy_cursor - 0x168; } found_before = find_addr < copy_addr; diff --git a/src/ui/map/draw_map_overlay.c b/src/ui/map/draw_map_overlay.c index e713beb030..46b7b52a76 100644 --- a/src/ui/map/draw_map_overlay.c +++ b/src/ui/map/draw_map_overlay.c @@ -470,7 +470,7 @@ void draw_map_overlay(void) { image_index = get_icon_frame(0xE99A, 5); scale = ((map_state->zoom[map_state->loaded] * 4.0f + 10.0f) * 0.75f) / 13.0f; angle = hero.motion.rot.f[2]; - flip = hero.state.control_mode == 0xF; + flip = hero.state.control_mode == HERO_MODE_GRIND; if (flip) { angle = fast_add_rotations(angle, 1.5707964f); } diff --git a/src/ui/map/map_filters.c b/src/ui/map/map_filters.c index 6b6b3672e1..86029912f7 100644 --- a/src/ui/map/map_filters.c +++ b/src/ui/map/map_filters.c @@ -58,9 +58,9 @@ int map_filter_l01_3(void *unused_input, float reveal_test_value) { struct Hero *hero_ptr = &hero; int hero_state_blocks_high_range_reveal = hero_ptr->state.control_mode == 16; - int hero_state_blocks_low_range_reveal = hero_ptr->state.control_mode == 17 || - hero_ptr->state.control_mode == 18 || - hero_ptr->base_condition == 1; + int hero_state_blocks_low_range_reveal = + hero_ptr->state.control_mode == HERO_MODE_SWIM || + hero_ptr->state.control_mode == HERO_MODE_WATER_SURFACE || hero_ptr->base_condition == 1; if (reveal_test_selector < 0xC8 && reveal_test_value >= 39.5f && reveal_test_value <= 42.5f && !hero_state_blocks_low_range_reveal) { @@ -115,7 +115,8 @@ int map_filter_l01_5(int reveal_test_selector, float reveal_test_value) { if (reveal_test_selector < 0x100) { struct Hero *hero_ptr = &hero; - return hero_ptr->state.control_mode == 17 || hero_ptr->state.control_mode == 18 || + return hero_ptr->state.control_mode == HERO_MODE_SWIM || + hero_ptr->state.control_mode == HERO_MODE_WATER_SURFACE || hero_ptr->base_condition == 1; } return (reveal_test_value >= 95.0f) ? 1 : 0; @@ -229,9 +230,9 @@ s32 map_filter_l07_1(s32 px, s32 py, f32 unused1, f32 unused2, f32 reveal_test_v s32 map_filter_l07_1(s32 px, s32 py, f32 unused1, f32 unused2, f32 reveal_test_value) { struct Hero *hero_ptr = &hero; - s32 hero_state_allows_polygon_reveal = hero_ptr->state.control_mode == 17 || - hero_ptr->state.control_mode == 18 || - hero_ptr->base_condition == 1; + s32 hero_state_allows_polygon_reveal = + hero_ptr->state.control_mode == HERO_MODE_SWIM || + hero_ptr->state.control_mode == HERO_MODE_WATER_SURFACE || hero_ptr->base_condition == 1; if (point_is_clockwise(px, py, 0x93, 0x168, 0x182, 0x168) != 0 && py >= 0x135 && D_001A03A8[0] != 0 && reveal_test_value >= 47.7f) { @@ -290,9 +291,10 @@ s32 map_filter_l07_3(s32 px, s32 py, f32 unused1, f32 unused2, f32 reveal_test_v s32 map_filter_l07_3(s32 px, s32 py, f32 unused1, f32 unused2, f32 reveal_test_value) { if (py < 0xBB) { struct Hero *hero_ptr = &hero; - s32 hero_state_blocks_low_y_reveal = hero_ptr->state.control_mode == 17 || - hero_ptr->state.control_mode == 18 || - hero_ptr->base_condition == 1; + s32 hero_state_blocks_low_y_reveal = + hero_ptr->state.control_mode == HERO_MODE_SWIM || + hero_ptr->state.control_mode == HERO_MODE_WATER_SURFACE || + hero_ptr->base_condition == 1; if (!hero_state_blocks_low_y_reveal && D_001A03BC != 0) { return 1; @@ -682,8 +684,8 @@ int map_filter_l11_3(int reveal_test_selector, float reveal_test_value) { struct Hero *hero_ptr = &hero; - int hero_state_allows_reveal = hero_ptr->state.control_mode == 17 || - hero_ptr->state.control_mode == 18 || + int hero_state_allows_reveal = hero_ptr->state.control_mode == HERO_MODE_SWIM || + hero_ptr->state.control_mode == HERO_MODE_WATER_SURFACE || hero_ptr->base_condition == 1; if (reveal_test_selector < 0x15F) { diff --git a/src/ui/menus/initialize_menu_preview_scene.c b/src/ui/menus/initialize_menu_preview_scene.c index d5fd7eaeaf..37b21e0e34 100644 --- a/src/ui/menus/initialize_menu_preview_scene.c +++ b/src/ui/menus/initialize_menu_preview_scene.c @@ -91,9 +91,9 @@ void initialize_menu_preview_scene(void) { s32 seq; preview_moby->flags &= 0xFFFD; ((struct Moby *)panel_slots[i])->update = (void (*)(struct Moby *))quad_moby_update; - ((struct Moby *)panel_slots[i])->pos.x = preview_camera.position.f[0]; - ((struct Moby *)panel_slots[i])->pos.y = preview_camera.position.f[1]; - ((struct Moby *)panel_slots[i])->pos.z = preview_camera.position.f[2]; + ((struct Moby *)panel_slots[i])->pos.x = game_camera.position.f[0]; + ((struct Moby *)panel_slots[i])->pos.y = game_camera.position.f[1]; + ((struct Moby *)panel_slots[i])->pos.z = game_camera.position.f[2]; ((struct Moby *)panel_slots[i])->rot.x = 0; ((struct Moby *)panel_slots[i])->rot.y = 0; ((struct Moby *)panel_slots[i])->rot.z = 0; diff --git a/src/ui/menus/item_preview/create_rotating_preview_moby.c b/src/ui/menus/item_preview/create_rotating_preview_moby.c index ad5a603f08..eecc05b328 100644 --- a/src/ui/menus/item_preview/create_rotating_preview_moby.c +++ b/src/ui/menus/item_preview/create_rotating_preview_moby.c @@ -34,9 +34,9 @@ s32 create_rotating_preview_moby(struct RotatingPreviewOwner *preview_owner) { if (moby != 0) { preview_owner->preview_moby = moby; moby->flags = 0; - moby->x = preview_camera.position.f[0] + 8.0f; - moby->y = preview_camera.position.f[1] + 0.5f; - moby->z = preview_camera.position.f[2] - 0.1f; + moby->x = game_camera.position.f[0] + 8.0f; + moby->y = game_camera.position.f[1] + 0.5f; + moby->z = game_camera.position.f[2] - 0.1f; moby->rotation_y = -1.9f; moby->update = rotate_preview_moby_x; *moby->preview_vars = preview_owner; diff --git a/src/ui/menus/item_preview/initialize_menu_preview_objects.c b/src/ui/menus/item_preview/initialize_menu_preview_objects.c index 08931600bc..a8ed463050 100644 --- a/src/ui/menus/item_preview/initialize_menu_preview_objects.c +++ b/src/ui/menus/item_preview/initialize_menu_preview_objects.c @@ -59,8 +59,8 @@ int initialize_menu_preview_objects(struct MenuScreen *preview) { held_flag--; } if (preview_moby != 0) { - struct PreviewCamera *camera = &preview_camera; - struct MenuSystem *g; + struct GameCamera *camera = &game_camera; + struct MenuSystem *g; preview->data.preview.moby = preview_moby; preview_moby->flags = 0; diff --git a/src/ui/menus/item_preview/update_item_preview_moby.c b/src/ui/menus/item_preview/update_item_preview_moby.c index bc5eb8944c..1dedd3f5b5 100644 --- a/src/ui/menus/item_preview/update_item_preview_moby.c +++ b/src/ui/menus/item_preview/update_item_preview_moby.c @@ -30,7 +30,7 @@ int update_item_preview_moby(struct MenuScreen *menu) { struct Moby *spawned_moby = create_menu_preview_moby(want); if (spawned_moby != 0) { - struct PreviewCamera *camera = &preview_camera; + struct GameCamera *camera = &game_camera; menu->data.preview.moby = spawned_moby; spawned_moby->flags = 0; diff --git a/src/ui/menus/missions/draw_missions_menu.c b/src/ui/menus/missions/draw_missions_menu.c index ae9f076fb7..8121d1be30 100644 --- a/src/ui/menus/missions/draw_missions_menu.c +++ b/src/ui/menus/missions/draw_missions_menu.c @@ -33,7 +33,7 @@ s32 draw_missions_menu(struct Menu *menu) { if (text_width >= w) { w = text_width; } - if (current_level_index != 0) { + if (current_level_index != LEVEL_VELDIN1) { text_width = measure_text_width_small(get_help_message_text(0x4EEF), -1); if (text_width >= w) { w = text_width; @@ -55,11 +55,11 @@ s32 draw_missions_menu(struct Menu *menu) { if (x < 2) { x = 2; } - step = menu->h / (current_level_index != 0 ? 7 : 6); + step = menu->h / (current_level_index != LEVEL_VELDIN1 ? 7 : 6); disable_font_color_codes(); y = step - 6; font_print_small(x, y, 0x80FFA888, get_help_message_text(0x4EEE), -1); - if (current_level_index != 0) { + if (current_level_index != LEVEL_VELDIN1) { y += step; font_print_small(x, y, 0x80FFA888, get_help_message_text(0x4EEF), -1); } diff --git a/src/ui/menus/save_data/loading_data_menu.c b/src/ui/menus/save_data/loading_data_menu.c index 7d012dc169..184c0ea37d 100644 --- a/src/ui/menus/save_data/loading_data_menu.c +++ b/src/ui/menus/save_data/loading_data_menu.c @@ -81,7 +81,7 @@ s32 loading_data_menu(struct LoadMenuDescriptor *menu) { return -1; } } - if ((mode_freeze_state != 0x10) && (mode_freeze_state != 1)) { + if ((save_card_state != CS_NEWCARD) && (save_card_state != CS_GOOD_SAVE)) { menu_system.next = menu_system.current->back; return 0; } diff --git a/src/ui/menus/save_data/run_state_handler.c b/src/ui/menus/save_data/run_state_handler.c index ad3e0cda8c..95971d7a00 100644 --- a/src/ui/menus/save_data/run_state_handler.c +++ b/src/ui/menus/save_data/run_state_handler.c @@ -3,16 +3,16 @@ #include "rnc/data_labels.h" #include "rnc/ui/menus/save_data.h" -/* One handler per memory card state; mode_freeze_state (0..0x18) picks it. */ +/* One handler per memory card state; save_card_state (0..0x18) picks it. */ extern void (*save_card_state_handlers[25])(void) __asm__("D_001A0438"); void run_state_handler(void) __asm__("FUN_00208840"); void run_state_handler(void) { - s32 state = mode_freeze_state; + s32 state = save_card_state; save_card_state_handlers[state](); D_00161280++; - if (mode_freeze_state != state) { + if (save_card_state != state) { D_00161280 = 0; } } diff --git a/src/ui/menus/save_data/save_card_state_check_save.c b/src/ui/menus/save_data/save_card_state_check_save.c index 3e02470322..a8c5fcb992 100644 --- a/src/ui/menus/save_data/save_card_state_check_save.c +++ b/src/ui/menus/save_data/save_card_state_check_save.c @@ -10,7 +10,7 @@ void save_card_state_check_save(void) { if (card_state->state == MEMCARD_DISPATCH_PENDING_OPERATION && card_state->pending_state < 0) { card_state->pending_state = MEMCARD_REQUEST_CHDIR; card_state->pending_card = 0; - mode_freeze_state = 0xB; + save_card_state = CS_CHECKING_SAVE; } } diff --git a/src/ui/menus/save_data/save_card_state_checking_save.c b/src/ui/menus/save_data/save_card_state_checking_save.c index 6df3cee85f..ec4e00b922 100644 --- a/src/ui/menus/save_data/save_card_state_checking_save.c +++ b/src/ui/menus/save_data/save_card_state_checking_save.c @@ -11,20 +11,20 @@ void save_card_state_checking_save(void) { struct MemoryCardState *card_state = &memory_card_state; int save_index; if (card_state->card[0].sync_result < -1) { - mode_freeze_state = 3; + save_card_state = CS_NOCARD; return; } save_index = card_state->card[0].save_index; if (save_index == -2) { if (card_state->card[0].free < 0x15E) { - mode_freeze_state = SAVE_CARD_STATE_INSUFFICIENT_FREE_SPACE; + save_card_state = SAVE_CARD_STATE_INSUFFICIENT_FREE_SPACE; } else { - mode_freeze_state = 0xC; + save_card_state = CS_NOSAVE; } return; } if (save_index >= -1) - mode_freeze_state = 0x10; + save_card_state = CS_NEWCARD; } extern __typeof__(save_card_state_checking_save) func_00208C00 diff --git a/src/ui/menus/save_data/save_card_state_create_failed.c b/src/ui/menus/save_data/save_card_state_create_failed.c index 76d400a50a..6bb445eedd 100644 --- a/src/ui/menus/save_data/save_card_state_create_failed.c +++ b/src/ui/menus/save_data/save_card_state_create_failed.c @@ -7,7 +7,7 @@ void save_card_state_create_failed(void) { if (mode_freeze_flags & 0x40) { return; } - mode_freeze_state = 3; + save_card_state = CS_NOCARD; } extern __typeof__(save_card_state_create_failed) func_00208E90 diff --git a/src/ui/menus/save_data/save_card_state_create_save_pending.c b/src/ui/menus/save_data/save_card_state_create_save_pending.c index b9d391cb1b..53d49fdd46 100644 --- a/src/ui/menus/save_data/save_card_state_create_save_pending.c +++ b/src/ui/menus/save_data/save_card_state_create_save_pending.c @@ -10,7 +10,7 @@ void save_card_state_create_save_pending(void) { card_state->pending_state < MEMCARD_QUERY_INFO) { card_state->pending_state = MEMCARD_BEGIN_CREATE_SAVE_DIRECTORY; card_state->pending_card = 0; - mode_freeze_state = 0xF; + save_card_state = CS_CREATING_SAVE; } } diff --git a/src/ui/menus/save_data/save_card_state_creating_save.c b/src/ui/menus/save_data/save_card_state_creating_save.c index 9d7b0b4138..d291335862 100644 --- a/src/ui/menus/save_data/save_card_state_creating_save.c +++ b/src/ui/menus/save_data/save_card_state_creating_save.c @@ -9,7 +9,7 @@ void save_card_state_creating_save(void) { struct MemoryCardState *card_state = &memory_card_state; if (card_state->state == MEMCARD_DISPATCH_PENDING_OPERATION && card_state->pending_state < 0) { if (card_state->err != 0) { - mode_freeze_state = 0x12; + save_card_state = CS_CREATE_FAILED; mode_freeze_flags |= 0x40; return; } @@ -17,7 +17,7 @@ void save_card_state_creating_save(void) { card_state->active_card = 0; card_state->card[0].save_index = 0; card_state->pending_card = 0; - mode_freeze_state = 0x10; + save_card_state = CS_NEWCARD; } } diff --git a/src/ui/menus/save_data/save_card_state_format_failed.c b/src/ui/menus/save_data/save_card_state_format_failed.c index 41cb67d63b..bbab27da14 100644 --- a/src/ui/menus/save_data/save_card_state_format_failed.c +++ b/src/ui/menus/save_data/save_card_state_format_failed.c @@ -7,7 +7,7 @@ void save_card_state_format_failed(void) { if (mode_freeze_flags & 0x40) { return; } - mode_freeze_state = 3; + save_card_state = CS_NOCARD; } extern __typeof__(save_card_state_format_failed) func_00208E68 diff --git a/src/ui/menus/save_data/save_card_state_format_pending.c b/src/ui/menus/save_data/save_card_state_format_pending.c index b5f41b60b6..b06bcf4f51 100644 --- a/src/ui/menus/save_data/save_card_state_format_pending.c +++ b/src/ui/menus/save_data/save_card_state_format_pending.c @@ -12,7 +12,7 @@ void save_card_state_format_pending(void) { card_state->pending_card = 0; card_state->pending_state = MEMCARD_REQUEST_FORMAT; } - mode_freeze_state = 8; + save_card_state = CS_FORMATTING; } extern __typeof__(save_card_state_format_pending) func_00208AF8 diff --git a/src/ui/menus/save_data/save_card_state_formatted.c b/src/ui/menus/save_data/save_card_state_formatted.c index 35cfd1b8e5..52667cb312 100644 --- a/src/ui/menus/save_data/save_card_state_formatted.c +++ b/src/ui/menus/save_data/save_card_state_formatted.c @@ -9,9 +9,9 @@ void save_card_state_formatted(void) __asm__("FUN_00208b88"); void save_card_state_formatted(void) { if (*(s32 *)((u8 *)&memory_card_state + 0x1C)) { - mode_freeze_state = 3; + save_card_state = CS_NOCARD; } else if (mode_freeze_flags & 6) { - mode_freeze_state = 0xA; + save_card_state = CS_CHECK_SAVE; } } diff --git a/src/ui/menus/save_data/save_card_state_formatting.c b/src/ui/menus/save_data/save_card_state_formatting.c index 2e94b3b4e3..e809683793 100644 --- a/src/ui/menus/save_data/save_card_state_formatting.c +++ b/src/ui/menus/save_data/save_card_state_formatting.c @@ -9,11 +9,11 @@ void save_card_state_formatting(void) { struct MemoryCardState *card_state = &memory_card_state; if (card_state->state == MEMCARD_DISPATCH_PENDING_OPERATION && card_state->pending_state < 0) { if (card_state->err != 0) { - mode_freeze_state = 0x11; + save_card_state = CS_FORMAT_FAILED; mode_freeze_flags |= 0x40; return; } - mode_freeze_state = 0xE; + save_card_state = CS_CREATE_SAVE_PENDING; } } diff --git a/src/ui/menus/save_data/save_card_state_good_save.c b/src/ui/menus/save_data/save_card_state_good_save.c index fa367cfa9e..f330c9b955 100644 --- a/src/ui/menus/save_data/save_card_state_good_save.c +++ b/src/ui/menus/save_data/save_card_state_good_save.c @@ -4,7 +4,7 @@ #include "rnc/globals.h" /* Clears the 4 and 2 flag bits of mode_freeze_flags, then picks the next - state into mode_freeze_state from the 0x80/0x100/0x200 bits and the + state into save_card_state from the 0x80/0x100/0x200 bits and the D_0013D290 record. The cross-jumped `b` back into the 0x80 arm is one GNU as pads as a short loop and ps2eeas did not; tools/ps2eeas_nops.py writes it as a .word. */ @@ -19,28 +19,28 @@ void save_card_state_good_save(void) { nf = mode_freeze_flags & ~2; mode_freeze_flags = nf; if (card_state->unkF4 == 0) { - mode_freeze_state = 3; + save_card_state = CS_NOCARD; return; } if (flags & 0x80) { - mode_freeze_state = 0x15; + save_card_state = CS_SAVE_FAILED; mode_freeze_flags = (nf ^ 0x80) | 0x40; return; } if (flags & 0x100) { - mode_freeze_state = 0x14; + save_card_state = CS_LOAD_FAILED; mode_freeze_flags = (nf ^ 0x100) | 0x40; return; } if (card_state->card[0].sync_result != 0) { card_state->unkF4 = 0; mode_freeze_flags = nf | 1; - mode_freeze_state = 2; + save_card_state = CS_WARNING; return; } if (flags & 0x200) { mode_freeze_flags = nf ^ 0x200; - mode_freeze_state = 0x16; + save_card_state = CS_SAVING; } } diff --git a/src/ui/menus/save_data/save_card_state_init.c b/src/ui/menus/save_data/save_card_state_init.c index 551f0a6a10..c58b86b988 100644 --- a/src/ui/menus/save_data/save_card_state_init.c +++ b/src/ui/menus/save_data/save_card_state_init.c @@ -5,7 +5,7 @@ void save_card_state_init(void) __asm__("FUN_002088a8"); void save_card_state_init(void) { - mode_freeze_state = 3; + save_card_state = CS_NOCARD; memory_card_state.card[0].sync_result = memory_card_state.result; memory_card_state.unkF4 = 0; } diff --git a/src/ui/menus/save_data/save_card_state_load_failed.c b/src/ui/menus/save_data/save_card_state_load_failed.c index bf6dfdf5ce..809936e131 100644 --- a/src/ui/menus/save_data/save_card_state_load_failed.c +++ b/src/ui/menus/save_data/save_card_state_load_failed.c @@ -7,7 +7,7 @@ void save_card_state_load_failed(void) { if (mode_freeze_flags & 0x40) { return; } - mode_freeze_state = 3; + save_card_state = CS_NOCARD; } extern __typeof__(save_card_state_load_failed) func_00208ED8 __attribute__((alias("FUN_00208ed8"))); diff --git a/src/ui/menus/save_data/save_card_state_new_card.c b/src/ui/menus/save_data/save_card_state_new_card.c index 3c0e7f08de..6a2b515272 100644 --- a/src/ui/menus/save_data/save_card_state_new_card.c +++ b/src/ui/menus/save_data/save_card_state_new_card.c @@ -11,22 +11,22 @@ void save_card_state_new_card(void) { int freeze_flags_without_bits_1_and_2 = freeze_flags_without_bit_2 & ~2; mode_freeze_flags = freeze_flags_without_bits_1_and_2; if (initial_freeze_flags & 0x80) { - mode_freeze_state = 0x15; + save_card_state = CS_SAVE_FAILED; mode_freeze_flags = (freeze_flags_without_bits_1_and_2 ^ 0x80) | 0x40; return; } if (initial_freeze_flags & 0x100) { - mode_freeze_state = 0x14; + save_card_state = CS_LOAD_FAILED; mode_freeze_flags = (freeze_flags_without_bits_1_and_2 ^ 0x100) | 0x40; return; } card_state = &memory_card_state; if (card_state->card[0].sync_result != 0) { - mode_freeze_state = 3; + save_card_state = CS_NOCARD; return; } if (card_state->unkF4 != 0) - mode_freeze_state = 1; + save_card_state = CS_GOOD_SAVE; } extern __typeof__(save_card_state_new_card) func_00208DD8 __attribute__((alias("FUN_00208dd8"))); diff --git a/src/ui/menus/save_data/save_card_state_no_card.c b/src/ui/menus/save_data/save_card_state_no_card.c index 6c3fd97639..0c3feafce3 100644 --- a/src/ui/menus/save_data/save_card_state_no_card.c +++ b/src/ui/menus/save_data/save_card_state_no_card.c @@ -7,7 +7,7 @@ void save_card_state_no_card(void) __asm__("FUN_002089a8"); void save_card_state_no_card(void) { struct MemoryCardState *card_state = &memory_card_state; card_state->pending_state = -1; - mode_freeze_state = 4; + save_card_state = CS_WAIT_FOR_CARD; card_state->pending_card = -1; } diff --git a/src/ui/menus/save_data/save_card_state_no_room.c b/src/ui/menus/save_data/save_card_state_no_room.c index ebbbe52647..7c08ccb537 100644 --- a/src/ui/menus/save_data/save_card_state_no_room.c +++ b/src/ui/menus/save_data/save_card_state_no_room.c @@ -6,7 +6,7 @@ void save_card_state_no_room(void) __asm__("FUN_00208eb8"); void save_card_state_no_room(void) { if (memory_card_state.card[0].sync_result != 0) { - mode_freeze_state = 3; + save_card_state = CS_NOCARD; } } diff --git a/src/ui/menus/save_data/save_card_state_no_save.c b/src/ui/menus/save_data/save_card_state_no_save.c index 1c0363f39c..da0e180da0 100644 --- a/src/ui/menus/save_data/save_card_state_no_save.c +++ b/src/ui/menus/save_data/save_card_state_no_save.c @@ -10,11 +10,11 @@ extern s32 mode_freeze_flags_gp __asm__("D_0015EEB4") __attribute__((sda)); void save_card_state_no_save(void) { struct MemoryCardState *card_state = &memory_card_state; if (card_state->card[0].sync_result != 0) { - mode_freeze_state = 3; + save_card_state = CS_NOCARD; return; } if (mode_freeze_flags_gp & 2) - mode_freeze_state = 0xD; + save_card_state = CS_PROMPT_CREATE_SAVE; } extern __typeof__(save_card_state_no_save) func_00208C70 __attribute__((alias("FUN_00208c70"))); diff --git a/src/ui/menus/save_data/save_card_state_prompt_begin_no_save.c b/src/ui/menus/save_data/save_card_state_prompt_begin_no_save.c index c534f400f5..cc4bb67431 100644 --- a/src/ui/menus/save_data/save_card_state_prompt_begin_no_save.c +++ b/src/ui/menus/save_data/save_card_state_prompt_begin_no_save.c @@ -9,10 +9,10 @@ void save_card_state_prompt_begin_no_save(void) __asm__("FUN_00208fe8"); void save_card_state_prompt_begin_no_save(void) { if (*(s32 *)((u8 *)&memory_card_state + 0x1C)) { - mode_freeze_state = 3; + save_card_state = CS_NOCARD; } else if (mode_freeze_flags & 0x20) { mode_freeze_flags ^= 0x20; - mode_freeze_state = 0xC; + save_card_state = CS_NOSAVE; } } diff --git a/src/ui/menus/save_data/save_card_state_prompt_begin_unformatted.c b/src/ui/menus/save_data/save_card_state_prompt_begin_unformatted.c index af491e4891..c215e5cec8 100644 --- a/src/ui/menus/save_data/save_card_state_prompt_begin_unformatted.c +++ b/src/ui/menus/save_data/save_card_state_prompt_begin_unformatted.c @@ -10,13 +10,13 @@ void save_card_state_prompt_begin_unformatted(void) { struct MemoryCardState *card_state = &memory_card_state; int freeze_flags_snapshot; if (card_state->card[0].sync_result != -2) { - mode_freeze_state = 3; + save_card_state = CS_NOCARD; return; } freeze_flags_snapshot = mode_freeze_flags_gp[0]; if (freeze_flags_snapshot & 0x20) { mode_freeze_flags = freeze_flags_snapshot ^ 0x20; - mode_freeze_state = 5; + save_card_state = CS_UNFORMATTED; } } diff --git a/src/ui/menus/save_data/save_card_state_prompt_create_save.c b/src/ui/menus/save_data/save_card_state_prompt_create_save.c index 0246bcc726..243b25ece0 100644 --- a/src/ui/menus/save_data/save_card_state_prompt_create_save.c +++ b/src/ui/menus/save_data/save_card_state_prompt_create_save.c @@ -9,22 +9,22 @@ void save_card_state_prompt_create_save(void) { int flags; if (memory_card_state.card[0].sync_result != 0) { - mode_freeze_state = 3; + save_card_state = CS_NOCARD; return; } flags = mode_freeze_flags; if (flags & 0x20) { mode_freeze_flags = flags ^ 0x20; if (boot_level_active != 0) { - mode_freeze_state = 0x18; + save_card_state = CS_PROMPT_BEGIN_NOSAVE; } else { - mode_freeze_state = 0xC; + save_card_state = CS_NOSAVE; } return; } if (flags & 0x10) { mode_freeze_flags = flags ^ 0x10; - mode_freeze_state = 0xE; + save_card_state = CS_CREATE_SAVE_PENDING; } } diff --git a/src/ui/menus/save_data/save_card_state_prompt_format.c b/src/ui/menus/save_data/save_card_state_prompt_format.c index bcb9bb297d..1d8b06291a 100644 --- a/src/ui/menus/save_data/save_card_state_prompt_format.c +++ b/src/ui/menus/save_data/save_card_state_prompt_format.c @@ -12,22 +12,22 @@ void save_card_state_prompt_format(void) { struct MemoryCardState *card_state = &memory_card_state; int mode_freeze_flags_snapshot; if (card_state->card[0].sync_result != -2) { - mode_freeze_state = 3; + save_card_state = CS_NOCARD; return; } mode_freeze_flags_snapshot = mode_freeze_flags_gp[0]; if (mode_freeze_flags_snapshot & 0x20) { mode_freeze_flags_gp[0] = mode_freeze_flags_snapshot ^ 0x20; if (boot_level_active != 0) { - mode_freeze_state = 0x17; + save_card_state = CS_PROMPT_BEGIN_UNFORMATTED; } else { - mode_freeze_state = 5; + save_card_state = CS_UNFORMATTED; } return; } if (mode_freeze_flags_snapshot & 8) { mode_freeze_flags = mode_freeze_flags_snapshot ^ 8; - mode_freeze_state = 7; + save_card_state = CS_FORMAT_PENDING; } } diff --git a/src/ui/menus/save_data/save_card_state_save_failed.c b/src/ui/menus/save_data/save_card_state_save_failed.c index 5969cb068e..6509ebc119 100644 --- a/src/ui/menus/save_data/save_card_state_save_failed.c +++ b/src/ui/menus/save_data/save_card_state_save_failed.c @@ -7,7 +7,7 @@ void save_card_state_save_failed(void) { if (mode_freeze_flags & 0x40) { return; } - mode_freeze_state = 3; + save_card_state = CS_NOCARD; } extern __typeof__(save_card_state_save_failed) func_00208F00 __attribute__((alias("FUN_00208f00"))); diff --git a/src/ui/menus/save_data/save_card_state_saving.c b/src/ui/menus/save_data/save_card_state_saving.c index cb88570e89..a545c8f007 100644 --- a/src/ui/menus/save_data/save_card_state_saving.c +++ b/src/ui/menus/save_data/save_card_state_saving.c @@ -20,11 +20,11 @@ void save_card_state_saving(void) { (memory_card_state.pending_state < MEMCARD_QUERY_INFO)) { if (memory_card_state.err != 0) { mode_freeze_init(3, 0); - mode_freeze_state = 0x15; + save_card_state = CS_SAVE_FAILED; flags = mode_freeze_flags | 0x40; mode_freeze_flags = flags; } else { - mode_freeze_state = 1; + save_card_state = CS_GOOD_SAVE; } } } diff --git a/src/ui/menus/save_data/save_card_state_unformatted.c b/src/ui/menus/save_data/save_card_state_unformatted.c index c73cddbf25..d135ed3707 100644 --- a/src/ui/menus/save_data/save_card_state_unformatted.c +++ b/src/ui/menus/save_data/save_card_state_unformatted.c @@ -10,11 +10,11 @@ extern s32 mode_freeze_flags_gp __asm__("D_0015EEB4") __attribute__((sda)); void save_card_state_unformatted(void) { struct MemoryCardState *card_state = &memory_card_state; if (card_state->card[0].sync_result != -2) { - mode_freeze_state = 3; + save_card_state = CS_NOCARD; return; } if (mode_freeze_flags_gp & 2) - mode_freeze_state = 6; + save_card_state = CS_PROMPT_FORMAT; } extern __typeof__(save_card_state_unformatted) func_00208A38 __attribute__((alias("FUN_00208a38"))); diff --git a/src/ui/menus/save_data/save_card_state_wait_for_card.c b/src/ui/menus/save_data/save_card_state_wait_for_card.c index cd7a89ce47..ee4c8ec57e 100644 --- a/src/ui/menus/save_data/save_card_state_wait_for_card.c +++ b/src/ui/menus/save_data/save_card_state_wait_for_card.c @@ -5,7 +5,7 @@ void save_card_state_wait_for_card(void) __asm__("FUN_002089d0"); -extern s32 mode_freeze_state_macro __asm__("D_0015EEB0") MACRO_ADDR; +extern s32 save_card_state_macro __asm__("D_0015EEB0") MACRO_ADDR; void save_card_state_wait_for_card(void) { struct MemoryCardState *card_state = &memory_card_state; @@ -13,16 +13,16 @@ void save_card_state_wait_for_card(void) { mode_freeze_flags &= ~0x20; sync_result = card_state->card[0].sync_result; if (sync_result == 0) { - mode_freeze_state_macro = 9; + save_card_state_macro = CS_FORMATTED; return; } if (sync_result == -1) { card_state->card[0].sync_result = 0; - mode_freeze_state_macro = 9; + save_card_state_macro = CS_FORMATTED; return; } if (sync_result == -2) - mode_freeze_state_macro = 5; + save_card_state_macro = CS_UNFORMATTED; } extern __typeof__(save_card_state_wait_for_card) func_002089D0 diff --git a/src/ui/menus/save_data/save_card_state_warning.c b/src/ui/menus/save_data/save_card_state_warning.c index e0124e2362..032351de4e 100644 --- a/src/ui/menus/save_data/save_card_state_warning.c +++ b/src/ui/menus/save_data/save_card_state_warning.c @@ -5,7 +5,7 @@ void save_card_state_warning(void) __asm__("FUN_00208980"); void save_card_state_warning(void) { if ((mode_freeze_flags ^ 1) & 1) { - mode_freeze_state = 3; + save_card_state = CS_NOCARD; } } diff --git a/src/ui/menus/save_data/saving_data_menu.c b/src/ui/menus/save_data/saving_data_menu.c index 54405993e2..dd9c54b397 100644 --- a/src/ui/menus/save_data/saving_data_menu.c +++ b/src/ui/menus/save_data/saving_data_menu.c @@ -88,7 +88,7 @@ s32 saving_data_menu(struct MenuScreen *menu) { block_23: block_24: - if ((mode_freeze_state != 0x10) && (mode_freeze_state != 1)) { + if ((save_card_state != CS_NEWCARD) && (save_card_state != CS_GOOD_SAVE)) { menu_system.next = (void *)menu_system.current->back; return 0; } diff --git a/src/ui/menus/save_data/saving_data_menu2.c b/src/ui/menus/save_data/saving_data_menu2.c index 8ab90105fb..fcbb282ee5 100644 --- a/src/ui/menus/save_data/saving_data_menu2.c +++ b/src/ui/menus/save_data/saving_data_menu2.c @@ -92,7 +92,7 @@ s32 saving_data_menu2(struct MenuScreen *w) { return -1; } } - if (mode_freeze_state != 0x10 && mode_freeze_state != 1) { + if (save_card_state != CS_NEWCARD && save_card_state != CS_GOOD_SAVE) { menu_system.next = menu_system.current->back; return 0; } diff --git a/src/ui/menus/streamed_moby/enter_streamed_moby_screen.c b/src/ui/menus/streamed_moby/enter_streamed_moby_screen.c index 879d2c674b..fe4b6b5e96 100644 --- a/src/ui/menus/streamed_moby/enter_streamed_moby_screen.c +++ b/src/ui/menus/streamed_moby/enter_streamed_moby_screen.c @@ -19,8 +19,8 @@ int enter_streamed_moby_screen(struct MenuStreamedMobyScreen *screen) { preview_moby = create_menu_preview_moby(0x7A5); screen->state = 0; if (preview_moby != 0) { - char *moby_sidecar; - struct PreviewCamera *camera = &preview_camera; + char *moby_sidecar; + struct GameCamera *camera = &game_camera; screen->mobys[0] = preview_moby; preview_moby->flags = 0; preview_moby->pos.x = camera->position.f[0] + 2.2f; diff --git a/src/ui/menus/system/setup_menu_display_text.c b/src/ui/menus/system/setup_menu_display_text.c index a05d6ddedc..a5a2eca164 100644 --- a/src/ui/menus/system/setup_menu_display_text.c +++ b/src/ui/menus/system/setup_menu_display_text.c @@ -21,10 +21,10 @@ extern void font_print_right(int, int, long, char *, int) __asm__("func_001F6940 int setup_menu_display_text(struct MenuScreen *menu) __asm__("FUN_0021ef78"); int setup_menu_display_text(struct MenuScreen *menu) { - char formatted_menu_text[0x100]; - struct PreviewCamera *camera = &preview_camera; - struct Moby *preview_moby = menu->data.preview.moby; - int count; + char formatted_menu_text[0x100]; + struct GameCamera *camera = &game_camera; + struct Moby *preview_moby = menu->data.preview.moby; + int count; preview_moby->pos.x = camera->position.f[0] + 8.0f; preview_moby->pos.y = camera->position.f[1] + setup_menu_moby_camera_y_offset; diff --git a/src/ui/menus/system/update_menu_entry_actions.c b/src/ui/menus/system/update_menu_entry_actions.c index 2dce6f7085..e7b5dbaf4d 100644 --- a/src/ui/menus/system/update_menu_entry_actions.c +++ b/src/ui/menus/system/update_menu_entry_actions.c @@ -83,7 +83,7 @@ s32 update_menu_entry_actions(struct MenuScreen *menu) { break; case MENU_ACTION_SET_NEXT_PAGE_OR_INITIALIZE_FREEZE: allocate_voice_for_target_entry(0, 0x11, menu->moby); - if (mode_freeze_state == 1 || mode_freeze_state == 0x10) { + if (save_card_state == CS_GOOD_SAVE || save_card_state == CS_NEWCARD) { menu_system.next = (struct MenuPage *)menu->data.list.items[menu->data.list.selected].param.value; } else { @@ -93,7 +93,7 @@ s32 update_menu_entry_actions(struct MenuScreen *menu) { break; case MENU_ACTION_SET_NEXT_PAGE_OR_INITIALIZE_TIMED_FREEZE: allocate_voice_for_target_entry(0, 0x11, menu->moby); - if (mode_freeze_state == 1 || mode_freeze_state == 0x10) { + if (save_card_state == CS_GOOD_SAVE || save_card_state == CS_NEWCARD) { menu_system.next = (struct MenuPage *)menu->data.list.items[menu->data.list.selected].param.value; } else { diff --git a/src/ui/text/draw_dialog_text.c b/src/ui/text/draw_dialog_text.c index 4bcae57dff..9663660889 100644 --- a/src/ui/text/draw_dialog_text.c +++ b/src/ui/text/draw_dialog_text.c @@ -77,26 +77,6 @@ void draw_dialog_text(void) { FREEZE_CHOICE_ALTERNATE_PAIRED_FOOTER_MESSAGE = 2, FREEZE_CHOICE_CENTERED_FOOTER_MESSAGE = 3 }; - enum { - MODE_FREEZE_TIMER_GATED_CENTERED_FOOTER_MESSAGE = 2, - MODE_FREEZE_BOOT_FLAG_GATED_PAIRED_OR_CENTERED_FOOTER_MESSAGE = 3, - MODE_FREEZE_SHARED_BOOT_FLAG_GATED_PAIRED_OR_CENTERED_FOOTER_MESSAGE = 4, - MODE_FREEZE_FORMATTED_CENTERED_FOOTER_MESSAGE = 5, - MODE_FREEZE_ALTERNATE_LEFT_PAIRED_FOOTER_MESSAGE = 6, - MODE_FREEZE_BODY_ONLY_MESSAGE = 7, - MODE_FREEZE_SHARED_BODY_ONLY_MESSAGE = 8, - MODE_FREEZE_ALTERNATE_BODY_ONLY_MESSAGE = 10, - MODE_FREEZE_SHARED_ALTERNATE_BODY_ONLY_MESSAGE = 11, - MODE_FREEZE_FLAG_GATED_PAIRED_OR_CENTERED_FOOTER_MESSAGE = 12, - MODE_FREEZE_SHARED_ALTERNATE_LEFT_PAIRED_FOOTER_MESSAGE = 13, - MODE_FREEZE_FOOTERLESS_MESSAGE = 14, - MODE_FREEZE_SHARED_FOOTERLESS_MESSAGE = 15, - MODE_FREEZE_CENTERED_FOOTER_MESSAGE = 17, - MODE_FREEZE_ALTERNATE_CENTERED_FOOTER_MESSAGE = 18, - MODE_FREEZE_CONDITIONAL_FORMATTED_PAIRED_OR_CENTERED_FOOTER_MESSAGE = 19, - MODE_FREEZE_PAIRED_FOOTER_MESSAGE = 23, - MODE_FREEZE_FORMATTED_PAIRED_FOOTER_MESSAGE = 24 - }; char formatted_dialog_text[0x200]; struct TextRegion box; @@ -172,51 +152,51 @@ void draw_dialog_text(void) { left = 0; mid = 0; right = 0; - switch (mode_freeze_state) { - case MODE_FREEZE_ALTERNATE_LEFT_PAIRED_FOOTER_MESSAGE: + switch (save_card_state) { + case CS_PROMPT_FORMAT: left = 0x524F; right = 0x524B; text = get_help_message_text(0x4FAF); break; - case MODE_FREEZE_FLAG_GATED_PAIRED_OR_CENTERED_FOOTER_MESSAGE: + case CS_NOSAVE: if (!(mode_freeze_flags & 2)) { mid = 0x4FA8; text = get_help_message_text(0x4FA7); break; } - case MODE_FREEZE_SHARED_ALTERNATE_LEFT_PAIRED_FOOTER_MESSAGE: + case CS_PROMPT_CREATE_SAVE: left = 0x524F; right = 0x524B; text = get_help_message_text(0x4FAD); break; - case MODE_FREEZE_ALTERNATE_BODY_ONLY_MESSAGE: - case MODE_FREEZE_SHARED_ALTERNATE_BODY_ONLY_MESSAGE: + case CS_CHECK_SAVE: + case CS_CHECKING_SAVE: text = get_help_message_text(0x4FC1); break; - case MODE_FREEZE_BODY_ONLY_MESSAGE: - case MODE_FREEZE_SHARED_BODY_ONLY_MESSAGE: + case CS_FORMAT_PENDING: + case CS_FORMATTING: text = get_help_message_text(0x4FB7); break; - case MODE_FREEZE_FOOTERLESS_MESSAGE: - case MODE_FREEZE_SHARED_FOOTERLESS_MESSAGE: + case CS_CREATE_SAVE_PENDING: + case CS_CREATING_SAVE: text = get_help_message_text(0x4FB8); break; - case MODE_FREEZE_CENTERED_FOOTER_MESSAGE: + case CS_FORMAT_FAILED: mid = 0x524A; text = get_help_message_text(0x4FBA); break; - case MODE_FREEZE_ALTERNATE_CENTERED_FOOTER_MESSAGE: + case CS_CREATE_FAILED: mid = 0x524A; text = get_help_message_text(0x4FBC); break; - case MODE_FREEZE_TIMER_GATED_CENTERED_FOOTER_MESSAGE: + case CS_WARNING: mid = 0x524A; text = get_help_message_text(0x4FA6); if (freeze.timer != 0) { mid = 0; } break; - case MODE_FREEZE_CONDITIONAL_FORMATTED_PAIRED_OR_CENTERED_FOOTER_MESSAGE: + case CS_NO_ROOM: if (mode_freeze_flags & 4) { mid = 0x4FA8; text = get_help_message_text(0x4FA7); @@ -235,15 +215,15 @@ void draw_dialog_text(void) { text = get_help_message_text(0x4FA9); } break; - case 21: + case CS_SAVE_FAILED: mid = 0x524A; text = get_help_message_text(0x4FBD); break; - case 20: + case CS_LOAD_FAILED: mid = 0x524A; text = get_help_message_text(0x4FBB); break; - case MODE_FREEZE_FORMATTED_PAIRED_FOOTER_MESSAGE: + case CS_PROMPT_BEGIN_NOSAVE: left = 0x524E; right = 0x524B; sprintf(formatted_dialog_text, @@ -254,13 +234,13 @@ void draw_dialog_text(void) { get_help_message_text(0x4FAA)); text = formatted_dialog_text; break; - case MODE_FREEZE_PAIRED_FOOTER_MESSAGE: + case CS_PROMPT_BEGIN_UNFORMATTED: left = 0x524E; right = 0x524B; text = get_help_message_text(0x4FB1); break; - case MODE_FREEZE_BOOT_FLAG_GATED_PAIRED_OR_CENTERED_FOOTER_MESSAGE: - case MODE_FREEZE_SHARED_BOOT_FLAG_GATED_PAIRED_OR_CENTERED_FOOTER_MESSAGE: + case CS_NOCARD: + case CS_WAIT_FOR_CARD: if (boot_level_active != 0 && (mode_freeze_flags & 2)) { left = 0x524E; right = 0x524B; @@ -270,7 +250,7 @@ void draw_dialog_text(void) { text = get_help_message_text(0x4FAC); } break; - case MODE_FREEZE_FORMATTED_CENTERED_FOOTER_MESSAGE: + case CS_UNFORMATTED: mid = 0x4FA8; sprintf(formatted_dialog_text, freeze_fmt_scsc, diff --git a/src/world/build_object_rotation_matrix.c b/src/world/build_object_rotation_matrix.c index 983886eba0..9efbf1433c 100644 --- a/src/world/build_object_rotation_matrix.c +++ b/src/world/build_object_rotation_matrix.c @@ -22,8 +22,8 @@ unsigned char build_object_rotation_matrix(void) { unsigned char flag = key[0xC]; float *keyframe_angles = (float *)(key + 0x10); char *camera_position; - struct PreviewCamera *camera_state; - float rotation_matrix[16]; + struct GameCamera *camera_state; + float rotation_matrix[16]; view_tan_half_fov = keyframe_angles[3]; update_view_context(); @@ -33,7 +33,7 @@ unsigned char build_object_rotation_matrix(void) { SceVu0RotMatrixX(rotation_matrix, rotation_matrix, *(float *)(key + 0x10)); SceVu0RotMatrixY(rotation_matrix, rotation_matrix, keyframe_angles[1]); sceVu0RotMatrixZ(rotation_matrix, rotation_matrix, keyframe_angles[2]); - camera_state = (struct PreviewCamera *)(camera_position - 0x140); + camera_state = (struct GameCamera *)(camera_position - 0x140); camera_state->forward.f[0] = -rotation_matrix[8]; camera_state->right.f[0] = -rotation_matrix[0]; camera_state->up.f[0] = rotation_matrix[4];